houxiao
2017-08-17 0c3bba1a4d7b652807dfb74e1a31012802bd2987
aaaaa

git-svn-id: http://192.168.1.226/svn/proxy@1019 454eff88-639b-444f-9e54-f578c98de674
2 文件已重命名
2个文件已修改
77 ■■■■■ 已修改文件
RtspFace/PL_AndroidMediaCodecDecoder_ndk.cpp 17 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
RtspFace/PL_H264FileFramer.cpp 38 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
RtspFace/PL_H264FileFramer.h 18 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
RtspFace/PL_RTSPServer2.cpp 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
RtspFace/PL_AndroidMediaCodecDecoder_ndk.cpp
@@ -136,12 +136,11 @@
        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}
@@ -202,9 +201,9 @@
        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++);
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;
RtspFace/PL_H264FileFramer.h
File was renamed from RtspFace/PL_AndroidMediaCodecFileFrame.h
@@ -1,25 +1,25 @@
#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();
@@ -29,7 +29,7 @@
    
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;
@@ -42,6 +42,6 @@
    int analyse_context();
};
PipeLineElem* create_PL_AndroidMediaCodecFileFrame();
PipeLineElem* create_PL_H264FileFramer();
#endif
RtspFace/PL_RTSPServer2.cpp
@@ -164,8 +164,8 @@
        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;