From 011ac4f6a9eb341490d998c16695dfb889806754 Mon Sep 17 00:00:00 2001 From: winlin Date: Mon, 30 Jan 2017 17:19:07 +0800 Subject: [PATCH] for #738, add mp4 demuxer to librtmp --- trunk/src/libs/srs_librtmp.cpp | 25 +++++++++++++++++++++++++ trunk/src/libs/srs_librtmp.hpp | 11 +++++++++++ 2 files changed, 36 insertions(+) diff --git a/trunk/src/libs/srs_librtmp.cpp b/trunk/src/libs/srs_librtmp.cpp index d8a8a1e57b..d45a3042b0 100644 --- a/trunk/src/libs/srs_librtmp.cpp +++ b/trunk/src/libs/srs_librtmp.cpp @@ -1544,6 +1544,31 @@ srs_bool srs_h264_startswith_annexb(char* h264_raw_data, int h264_raw_size, int* return srs_avc_startswith_annexb(&stream, pnb_start_code); } + +struct Mp4Context +{ + SrsFileReader reader; +}; + +srs_mp4_t srs_mp4_open_read(const char* file) +{ + int ret = ERROR_SUCCESS; + + Mp4Context* mp4 = new Mp4Context(); + + if ((ret = mp4->reader.open(file)) != ERROR_SUCCESS) { + srs_freep(mp4); + return NULL; + } + + return mp4; +} + +void srs_mp4_close(srs_mp4_t mp4) +{ + Mp4Context* context = (Mp4Context*)mp4; + srs_freep(context); +} struct FlvContext { diff --git a/trunk/src/libs/srs_librtmp.hpp b/trunk/src/libs/srs_librtmp.hpp index 85164520bf..6a7262d9fc 100644 --- a/trunk/src/libs/srs_librtmp.hpp +++ b/trunk/src/libs/srs_librtmp.hpp @@ -501,6 +501,17 @@ extern srs_bool srs_h264_startswith_annexb( char* h264_raw_data, int h264_raw_size, int* pnb_start_code ); + +/************************************************************* + ************************************************************* + * MP4 muxer and demuxer. + * @example /trunk/research/librtmp/srs_ingest_mp4.c + ************************************************************* + *************************************************************/ +typedef void* srs_mp4_t; +/* Open mp4 file for muxer(write) or demuxer(read). */ +extern srs_mp4_t srs_mp4_open_read(const char* file); +extern void srs_mp4_close(srs_mp4_t mp4); /************************************************************* **************************************************************