aaaaa
git-svn-id: http://192.168.1.226/svn/proxy@1019 454eff88-639b-444f-9e54-f578c98de674
| | |
| | | AMediaFormat_setBuffer(format, "csd-1", pps.sPropBytes, pps.sPropLength); // pps
|
| | | */
|
| | |
|
| | | // J0LgKI1oCgPaEAAAAwAQAAADAoDxB6gA,KM4ySA==
|
| | | uint8_t sps[] = {0x27,0x42,0xe0,0x28,0x8d,0x68,0x0a,0x03,0xda,0x10,0x00,0x00,0x03,0x00,0x10,0x00,0x00,0x03,0x02,0x80,0xf1,0x07,0xa8,0x00};
|
| | | uint8_t pps[] = {0x28,0xce,0x32,0x48};
|
| | | AMediaFormat_setBuffer(format, "csd-0", sps, sizeof(sps)); // sps
|
| | | AMediaFormat_setBuffer(format, "csd-1", pps, sizeof(pps)); // pps
|
| | |
|
| | | // J0LgKI1oCgPaEAAAAwAQAAADAoDxB6gA,KM4ySA==
|
| | | //uint8_t sps[] = {0x27,0x42,0xe0,0x28,0x8d,0x68,0x0a,0x03,0xda,0x10,0x00,0x00,0x03,0x00,0x10,0x00,0x00,0x03,0x02,0x80,0xf1,0x07,0xa8,0x00};
|
| | | //uint8_t pps[] = {0x28,0xce,0x32,0x48};
|
| | | //AMediaFormat_setBuffer(format, "csd-0", sps, sizeof(sps)); // sps
|
| | | //AMediaFormat_setBuffer(format, "csd-1", pps, sizeof(pps)); // pps
|
| | |
|
| | | // should like:
|
| | | // mime: string(video/avc), durationUs: int64(10000000), width: int32(480), height: int32(360), max-input-size: int32(55067), csd-0: data, csd-1: data}
|
| | |
| | | return false;
|
| | | }
|
| | |
|
| | | static FILE *pFile = fopen("/data/bb.264", "wb");
|
| | | fwrite(frame->buffer, sizeof(char), frame->buffSize, pFile);
|
| | | fflush(pFile);
|
| | | //static FILE *pFile = fopen("/data/bb.264", "wb");
|
| | | //fwrite(frame->buffer, sizeof(char), frame->buffSize, pFile);
|
| | | //fflush(pFile);
|
| | |
|
| | | ssize_t bufidx = AMediaCodec_dequeueInputBuffer(in->codec, 2000);
|
| | | LOGP(DEBUG, "input buffer bufidx=%zd, inputFrameCount=%d", bufidx, in->inputFrameCount++);
|
File was renamed from RtspFace/PL_AndroidMediaCodecFileFrame.cpp |
| | |
| | | #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"
|
| | |
|
| | |
| | |
|
| | | size_t inputFrameCount;
|
| | |
|
| | | PL_AndroidMediaCodecFileFrame_Config config;
|
| | |
|
| | | AMediaCodec* codec;
|
| | | PL_H264FileFramer_Config config;
|
| | |
|
| | | bool payOK;
|
| | |
|
| | |
| | |
|
| | | inputFrameCount = 0;
|
| | |
|
| | | PL_AndroidMediaCodecFileFrame_Config _config;
|
| | | PL_H264FileFramer_Config _config;
|
| | | config = _config;
|
| | |
|
| | | codec = nullptr;//#todo destory
|
| | |
| | | }
|
| | | };
|
| | |
|
| | | 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)
|
| | |
| | | return true;
|
| | | }
|
| | |
|
| | | void PL_AndroidMediaCodecFileFrame::finit()
|
| | | void PL_H264FileFramer::finit()
|
| | | {
|
| | | PL_AMCE_Internal* in = (PL_AMCE_Internal*)internal;
|
| | | //todo release codec
|
| | |
| | | return false;
|
| | | }
|
| | |
|
| | | bool PL_AndroidMediaCodecFileFrame::pay(const PipeMaterial& pm)
|
| | | bool PL_H264FileFramer::pay(const PipeMaterial& pm)
|
| | | {
|
| | | PL_AMCE_Internal* in = (PL_AMCE_Internal*)internal;
|
| | |
|
| | |
| | | return in->payOK;
|
| | | }
|
| | |
|
| | | bool PL_AndroidMediaCodecFileFrame::gain(PipeMaterial& pm)
|
| | | bool PL_H264FileFramer::gain(PipeMaterial& pm)
|
| | | {
|
| | | PL_AMCE_Internal* in = (PL_AMCE_Internal*)internal;
|
| | |
|
| | |
| | |
|
| | | 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();
|
| | |
| | | return 1;
|
| | | }
|
| | |
|
| | | int PL_AndroidMediaCodecFileFrame::analyse_context()
|
| | | int PL_H264FileFramer::analyse_context()
|
| | | {
|
| | | int _count = 0;
|
| | | int _begin = -1;
|
File was renamed from RtspFace/PL_AndroidMediaCodecFileFrame.h |
| | |
| | | #ifndef _PL_ANDROIDMEDIACODECFILEFRAME_H_
|
| | | #define _PL_ANDROIDMEDIACODECFILEFRAME_H_
|
| | | #ifndef _PL_H264FILEFRAMER_H_
|
| | | #define _PL_H264FILEFRAMER_H_
|
| | |
|
| | | #include "PipeLine.h"
|
| | |
|
| | | struct PL_AndroidMediaCodecFileFrame_Config
|
| | | struct PL_H264FileFramer_Config
|
| | | {
|
| | | char sz_path[256];
|
| | | bool b_loop_play;
|
| | |
|
| | | PL_AndroidMediaCodecFileFrame_Config() :
|
| | | PL_H264FileFramer_Config() :
|
| | | b_loop_play(false)
|
| | | {
|
| | | memset(sz_path,0,256);
|
| | | }
|
| | | };
|
| | |
|
| | | class PL_AndroidMediaCodecFileFrame : public PipeLineElem
|
| | | class PL_H264FileFramer : public PipeLineElem
|
| | | {
|
| | | public:
|
| | | PL_AndroidMediaCodecFileFrame();
|
| | | virtual ~PL_AndroidMediaCodecFileFrame();
|
| | | PL_H264FileFramer();
|
| | | virtual ~PL_H264FileFramer();
|
| | |
|
| | | virtual bool init(void* args);
|
| | | virtual void finit();
|
| | |
| | |
|
| | | private:
|
| | | void* internal;
|
| | | bool m_b_loop_play;
|
| | | bool m_b_loop_play;//#todo move to config
|
| | | std::string m_str_context;
|
| | | std::string m_str_old_context;
|
| | | std::string m_str_buf;
|
| | |
| | | int analyse_context();
|
| | | };
|
| | |
|
| | | PipeLineElem* create_PL_AndroidMediaCodecFileFrame();
|
| | | PipeLineElem* create_PL_H264FileFramer();
|
| | |
|
| | | #endif
|
| | |
| | | if (_this->lastBuffer == nullptr)
|
| | | return false;
|
| | |
|
| | | buffer = _this->lastBuffer->buffer; // #todo send nalu
|
| | | buffSize = _this->lastBuffer->buffSize;
|
| | | buffer = _this->lastBuffer->buffer + 4; // #todo send nalu
|
| | | buffSize = _this->lastBuffer->buffSize - 4;
|
| | | //LOG_WARN << "sizeS=" << buffSize << LOG_ENDL;
|
| | |
|
| | | //LOG_INFO << "DeliverFrameCallback buffSize=" << buffSize << LOG_ENDL;
|