houxiao
2017-08-17 0c3bba1a4d7b652807dfb74e1a31012802bd2987
RtspFace/PL_H264FileFramer.cpp
File was renamed from RtspFace/PL_AndroidMediaCodecFileFrame.cpp
@@ -1,18 +1,12 @@
#include "PL_AndroidMediaCodecFileFrame.h"
#include "PL_H264FileFramer.h"
#include "MaterialBuffer.h"
#include "logger.h"
#include "MediaHelper.h"
#include <media/NdkMediaCodec.h>
#include <media/NdkMediaFormat.h>
#include <android/bitmap.h>
#include "my_timer.hpp"
#include <stdlib.h>
#include <fstream>
using namespace std;
#include <liveMedia/liveMedia.hh>
#define H264_HEAD "01"
@@ -24,9 +18,7 @@
   
   size_t inputFrameCount;
   PL_AndroidMediaCodecFileFrame_Config config;
   AMediaCodec* codec;
   PL_H264FileFramer_Config config;
   bool payOK;
@@ -52,7 +44,7 @@
      
      inputFrameCount = 0;
      PL_AndroidMediaCodecFileFrame_Config _config;
      PL_H264FileFramer_Config _config;
      config = _config;
      
      codec = nullptr;//#todo destory
@@ -64,28 +56,28 @@
   }
};
PipeLineElem* create_PL_AndroidMediaCodecFileFrame()
PipeLineElem* create_PL_H264FileFramer()
{
   return new PL_AndroidMediaCodecFileFrame;
   return new PL_H264FileFramer;
}
PL_AndroidMediaCodecFileFrame::PL_AndroidMediaCodecFileFrame() : internal(new PL_AMCE_Internal)
PL_H264FileFramer::PL_H264FileFramer() : internal(new PL_AMCE_Internal)
,m_b_loop_play(false),m_begin(-1),m_current_time(0)
{
}
PL_AndroidMediaCodecFileFrame::~PL_AndroidMediaCodecFileFrame()
PL_H264FileFramer::~PL_H264FileFramer()
{
   delete (PL_AMCE_Internal*)internal;
   internal= nullptr;
}
bool PL_AndroidMediaCodecFileFrame::init(void* args)
bool PL_H264FileFramer::init(void* args)
{
   PL_AMCE_Internal* in = (PL_AMCE_Internal*)internal;
   in->reset();
   PL_AndroidMediaCodecFileFrame_Config* config = (PL_AndroidMediaCodecFileFrame_Config*)args;
   PL_H264FileFramer_Config* config = (PL_H264FileFramer_Config*)args;
    int ret = read_file(config->sz_path);
    if(1!=ret)
@@ -140,7 +132,7 @@
   return true;
}
void PL_AndroidMediaCodecFileFrame::finit()
void PL_H264FileFramer::finit()
{
   PL_AMCE_Internal* in = (PL_AMCE_Internal*)internal;
   //todo release codec
@@ -179,7 +171,7 @@
   return false;
}
bool PL_AndroidMediaCodecFileFrame::pay(const PipeMaterial& pm)
bool PL_H264FileFramer::pay(const PipeMaterial& pm)
{
   PL_AMCE_Internal* in = (PL_AMCE_Internal*)internal;
@@ -190,7 +182,7 @@
   return in->payOK;
}
bool PL_AndroidMediaCodecFileFrame::gain(PipeMaterial& pm)
bool PL_H264FileFramer::gain(PipeMaterial& pm)
{
   PL_AMCE_Internal* in = (PL_AMCE_Internal*)internal;
@@ -342,13 +334,13 @@
   
   return false;
}
int PL_AndroidMediaCodecFileFrame::write_file(const char* p_path,const char* p_content,int nlength)
int PL_H264FileFramer::write_file(const char* p_path,const char* p_content,int nlength)
{
    std::fstream outfile(p_path, std::ios_base::out | std::ios_base::binary);
    outfile.write(p_content, nlength);
    outfile.close();
}
int PL_AndroidMediaCodecFileFrame::read_file(const char* p_path)
int PL_H264FileFramer::read_file(const char* p_path)
{
    std::fstream infile(p_path, std::ios_base::in | std::ios_base::binary | ios::ate);
    size_t nSize = infile.tellg();
@@ -366,7 +358,7 @@
    return 1;
}
int PL_AndroidMediaCodecFileFrame::analyse_context()
int PL_H264FileFramer::analyse_context()
{
    int _count = 0;
    int _begin = -1;