1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-03-09 15:49:59 +00:00

for #299, refine the encoder object name

This commit is contained in:
winlin 2017-02-12 21:50:02 +08:00
parent 2a4f57a587
commit 2fcd3972c1
17 changed files with 152 additions and 158 deletions

View file

@ -277,7 +277,7 @@ int SrsDvrSegmenter::on_reload_vhost_dvr(std::string vhost)
SrsDvrFlvSegmenter::SrsDvrFlvSegmenter()
{
enc = new SrsFlvEncoder();
enc = new SrsFlvTransmuxer();
duration_offset = 0;
filesize_offset = 0;
@ -357,7 +357,7 @@ int SrsDvrFlvSegmenter::open_encoder()
filesize_offset = 0;
srs_freep(enc);
enc = new SrsFlvEncoder();
enc = new SrsFlvTransmuxer();
if ((ret = enc->initialize(fs)) != ERROR_SUCCESS) {
return ret;

View file

@ -39,7 +39,7 @@ class SrsBuffer;
class SrsRtmpJitter;
class SrsSharedPtrMessage;
class SrsFileWriter;
class SrsFlvEncoder;
class SrsFlvTransmuxer;
class SrsDvrPlan;
class SrsJsonAny;
class SrsJsonObject;
@ -129,7 +129,7 @@ class SrsDvrFlvSegmenter : public SrsDvrSegmenter
{
private:
// The FLV encoder, for FLV target.
SrsFlvEncoder* enc;
SrsFlvTransmuxer* enc;
private:
// The offset of file for duration value.
// The next 8 bytes is the double value.

View file

@ -69,12 +69,12 @@ SrsHlsSegment::SrsHlsSegment(SrsTsContext* c, SrsAudioCodecId ac, SrsVideoCodecI
segment_start_dts = 0;
is_sequence_header = false;
writer = new SrsFileWriter();
muxer = new SrsTsMuxer(writer, c, ac, vc);
tscw = new SrsTsContextWriter(writer, c, ac, vc);
}
SrsHlsSegment::~SrsHlsSegment()
{
srs_freep(muxer);
srs_freep(tscw);
srs_freep(writer);
}
@ -473,7 +473,7 @@ int SrsHlsMuxer::segment_open(int64_t segment_start_dts)
// open temp ts file.
std::string tmp_file = current->full_path + ".tmp";
if ((ret = current->muxer->open(tmp_file.c_str())) != ERROR_SUCCESS) {
if ((ret = current->tscw->open(tmp_file.c_str())) != ERROR_SUCCESS) {
srs_error("open hls muxer failed. ret=%d", ret);
return ret;
}
@ -537,10 +537,10 @@ bool SrsHlsMuxer::is_segment_absolutely_overflow()
bool SrsHlsMuxer::pure_audio()
{
return current && current->muxer && current->muxer->video_codec() == SrsVideoCodecIdDisabled;
return current && current->tscw && current->tscw->video_codec() == SrsVideoCodecIdDisabled;
}
int SrsHlsMuxer::flush_audio(SrsTsCache* cache)
int SrsHlsMuxer::flush_audio(SrsTsMessageCache* cache)
{
int ret = ERROR_SUCCESS;
@ -557,7 +557,7 @@ int SrsHlsMuxer::flush_audio(SrsTsCache* cache)
// update the duration of segment.
current->update_duration(cache->audio->pts);
if ((ret = current->muxer->write_audio(cache->audio)) != ERROR_SUCCESS) {
if ((ret = current->tscw->write_audio(cache->audio)) != ERROR_SUCCESS) {
return ret;
}
@ -567,7 +567,7 @@ int SrsHlsMuxer::flush_audio(SrsTsCache* cache)
return ret;
}
int SrsHlsMuxer::flush_video(SrsTsCache* cache)
int SrsHlsMuxer::flush_video(SrsTsMessageCache* cache)
{
int ret = ERROR_SUCCESS;
@ -586,7 +586,7 @@ int SrsHlsMuxer::flush_video(SrsTsCache* cache)
// update the duration of segment.
current->update_duration(cache->video->dts);
if ((ret = current->muxer->write_video(cache->video)) != ERROR_SUCCESS) {
if ((ret = current->tscw->write_video(cache->video)) != ERROR_SUCCESS) {
return ret;
}
@ -639,7 +639,7 @@ int SrsHlsMuxer::segment_close(string log_desc)
current->segment_start_dts);
// close the muxer of finished segment.
srs_freep(current->muxer);
srs_freep(current->tscw);
std::string full_path = current->full_path;
current = NULL;
@ -827,14 +827,14 @@ int SrsHlsMuxer::_refresh_m3u8(string m3u8_file)
SrsHlsController::SrsHlsController()
{
ts = new SrsTsCache();
tsmc = new SrsTsMessageCache();
muxer = new SrsHlsMuxer();
}
SrsHlsController::~SrsHlsController()
{
srs_freep(muxer);
srs_freep(ts);
srs_freep(tsmc);
}
int SrsHlsController::initialize()
@ -920,7 +920,7 @@ int SrsHlsController::on_unpublish()
{
int ret = ERROR_SUCCESS;
if ((ret = muxer->flush_audio(ts)) != ERROR_SUCCESS) {
if ((ret = muxer->flush_audio(tsmc)) != ERROR_SUCCESS) {
srs_error("m3u8 muxer flush audio failed. ret=%d", ret);
return ret;
}
@ -948,7 +948,7 @@ int SrsHlsController::write_audio(SrsAudioFrame* frame, int64_t pts)
int ret = ERROR_SUCCESS;
// write audio to cache.
if ((ret = ts->cache_audio(frame, pts)) != ERROR_SUCCESS) {
if ((ret = tsmc->cache_audio(frame, pts)) != ERROR_SUCCESS) {
return ret;
}
@ -960,16 +960,16 @@ int SrsHlsController::write_audio(SrsAudioFrame* frame, int64_t pts)
// @see https://github.com/ossrs/srs/issues/151
// we use absolutely overflow of segment to make jwplayer/ffplay happy
// @see https://github.com/ossrs/srs/issues/151#issuecomment-71155184
if (ts->audio && muxer->is_segment_absolutely_overflow()) {
if (tsmc->audio && muxer->is_segment_absolutely_overflow()) {
srs_info("hls: absolute audio reap segment.");
if ((ret = reap_segment("audio", ts->audio->pts)) != ERROR_SUCCESS) {
if ((ret = reap_segment("audio", tsmc->audio->pts)) != ERROR_SUCCESS) {
return ret;
}
}
// for pure audio, aggregate some frame to one.
if (muxer->pure_audio() &&ts->audio) {
if (pts - ts->audio->start_pts < SRS_CONSTS_HLS_PURE_AUDIO_AGGREGATE) {
if (muxer->pure_audio() && tsmc->audio) {
if (pts - tsmc->audio->start_pts < SRS_CONSTS_HLS_PURE_AUDIO_AGGREGATE) {
return ret;
}
}
@ -978,7 +978,7 @@ int SrsHlsController::write_audio(SrsAudioFrame* frame, int64_t pts)
// it's ok for the hls overload, or maybe cause the audio corrupt,
// which introduced by aggregate the audios to a big one.
// @see https://github.com/ossrs/srs/issues/512
if ((ret = muxer->flush_audio(ts)) != ERROR_SUCCESS) {
if ((ret = muxer->flush_audio(tsmc)) != ERROR_SUCCESS) {
return ret;
}
@ -990,7 +990,7 @@ int SrsHlsController::write_video(SrsVideoFrame* frame, int64_t dts)
int ret = ERROR_SUCCESS;
// write video to cache.
if ((ret = ts->cache_video(frame, dts)) != ERROR_SUCCESS) {
if ((ret = tsmc->cache_video(frame, dts)) != ERROR_SUCCESS) {
return ret;
}
@ -1001,14 +1001,14 @@ int SrsHlsController::write_video(SrsVideoFrame* frame, int64_t dts)
// b. always reap when not wait keyframe.
if (!muxer->wait_keyframe() || frame->frame_type == SrsVideoAvcFrameTypeKeyFrame) {
// reap the segment, which will also flush the video.
if ((ret = reap_segment("video", ts->video->dts)) != ERROR_SUCCESS) {
if ((ret = reap_segment("video", tsmc->video->dts)) != ERROR_SUCCESS) {
return ret;
}
}
}
// flush video when got one
if ((ret = muxer->flush_video(ts)) != ERROR_SUCCESS) {
if ((ret = muxer->flush_video(tsmc)) != ERROR_SUCCESS) {
srs_error("m3u8 muxer flush video failed. ret=%d", ret);
return ret;
}
@ -1036,7 +1036,7 @@ int SrsHlsController::reap_segment(string log_desc, int64_t segment_start_dts)
}
// segment open, flush video first.
if ((ret = muxer->flush_video(ts)) != ERROR_SUCCESS) {
if ((ret = muxer->flush_video(tsmc)) != ERROR_SUCCESS) {
srs_error("m3u8 muxer flush video failed. ret=%d", ret);
return ret;
}
@ -1044,7 +1044,7 @@ int SrsHlsController::reap_segment(string log_desc, int64_t segment_start_dts)
// segment open, flush the audio.
// @see: ngx_rtmp_hls_open_fragment
/* start fragment with audio to make iPhone happy */
if ((ret = muxer->flush_audio(ts)) != ERROR_SUCCESS) {
if ((ret = muxer->flush_audio(tsmc)) != ERROR_SUCCESS) {
srs_error("m3u8 muxer flush audio failed. ret=%d", ret);
return ret;
}

View file

@ -40,7 +40,7 @@ class SrsFormat;
class SrsSharedPtrMessage;
class SrsAmf0Object;
class SrsRtmpJitter;
class SrsTsMuxer;
class SrsTsContextWriter;
class SrsRequest;
class SrsPithyPrint;
class SrsSource;
@ -48,9 +48,8 @@ class SrsOriginHub;
class SrsFileWriter;
class SrsSimpleStream;
class SrsTsAacJitter;
class SrsTsCache;
class SrsTsMessageCache;
class SrsHlsSegment;
class SrsTsCache;
class SrsTsContext;
/**
@ -70,9 +69,10 @@ public:
std::string uri;
// ts full file to write.
std::string full_path;
// the muxer to write ts.
// the underlayer file writer.
SrsFileWriter* writer;
SrsTsMuxer* muxer;
// The TS context writer to write TS to file.
SrsTsContextWriter* tscw;
// current segment start dts for m3u8
int64_t segment_start_dts;
// whether current segement is sequence header.
@ -228,8 +228,8 @@ public:
* whether current hls muxer is pure audio mode.
*/
virtual bool pure_audio();
virtual int flush_audio(SrsTsCache* cache);
virtual int flush_video(SrsTsCache* cache);
virtual int flush_audio(SrsTsMessageCache* cache);
virtual int flush_video(SrsTsMessageCache* cache);
/**
* close segment(ts).
* @param log_desc the description for log.
@ -261,10 +261,10 @@ class SrsHlsController
{
private:
// The HLS muxer to reap ts and m3u8.
// The TS is cached to SrsTsCache then flush to ts segment.
// The TS is cached to SrsTsMessageCache then flush to ts segment.
SrsHlsMuxer* muxer;
// The TS cache
SrsTsCache* ts;
SrsTsMessageCache* tsmc;
public:
SrsHlsController();
virtual ~SrsHlsController();

View file

@ -47,10 +47,6 @@ class SrsSource;
class SrsRequest;
class SrsConsumer;
class SrsStSocket;
class SrsTsEncoder;
class SrsAacEncoder;
class SrsMp3Encoder;
class SrsFlvEncoder;
class SrsHttpParser;
class ISrsHttpMessage;
class SrsHttpHandler;

View file

@ -182,7 +182,7 @@ ISrsBufferEncoder::~ISrsBufferEncoder()
SrsTsStreamEncoder::SrsTsStreamEncoder()
{
enc = new SrsTsEncoder();
enc = new SrsTsTransmuxer();
}
SrsTsStreamEncoder::~SrsTsStreamEncoder()
@ -230,7 +230,7 @@ int SrsTsStreamEncoder::dump_cache(SrsConsumer* /*consumer*/, SrsRtmpJitterAlgor
SrsFlvStreamEncoder::SrsFlvStreamEncoder()
{
enc = new SrsFlvEncoder();
enc = new SrsFlvTransmuxer();
}
SrsFlvStreamEncoder::~SrsFlvStreamEncoder()
@ -298,7 +298,7 @@ int SrsFastFlvStreamEncoder::write_tags(SrsSharedPtrMessage** msgs, int count)
SrsAacStreamEncoder::SrsAacStreamEncoder()
{
enc = new SrsAacEncoder();
enc = new SrsAacTransmuxer();
cache = NULL;
}
@ -350,7 +350,7 @@ int SrsAacStreamEncoder::dump_cache(SrsConsumer* consumer, SrsRtmpJitterAlgorith
SrsMp3StreamEncoder::SrsMp3StreamEncoder()
{
enc = new SrsMp3Encoder();
enc = new SrsMp3Transmuxer();
cache = NULL;
}

View file

@ -32,6 +32,11 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include <srs_app_http_conn.hpp>
class SrsAacTransmuxer;
class SrsMp3Transmuxer;
class SrsFlvTransmuxer;
class SrsTsTransmuxer;
/**
* for the srs http stream cache,
* for example, the audio stream cache to make android(weixin) happy.
@ -98,7 +103,7 @@ public:
class SrsFlvStreamEncoder : public ISrsBufferEncoder
{
protected:
SrsFlvEncoder* enc;
SrsFlvTransmuxer* enc;
public:
SrsFlvStreamEncoder();
virtual ~SrsFlvStreamEncoder();
@ -136,7 +141,7 @@ public:
class SrsTsStreamEncoder : public ISrsBufferEncoder
{
private:
SrsTsEncoder* enc;
SrsTsTransmuxer* enc;
public:
SrsTsStreamEncoder();
virtual ~SrsTsStreamEncoder();
@ -156,7 +161,7 @@ public:
class SrsAacStreamEncoder : public ISrsBufferEncoder
{
private:
SrsAacEncoder* enc;
SrsAacTransmuxer* enc;
SrsBufferCache* cache;
public:
SrsAacStreamEncoder();
@ -177,7 +182,7 @@ public:
class SrsMp3StreamEncoder : public ISrsBufferEncoder
{
private:
SrsMp3Encoder* enc;
SrsMp3Transmuxer* enc;
SrsBufferCache* cache;
public:
SrsMp3StreamEncoder();
@ -266,6 +271,7 @@ public:
* the http stream server instance,
* serve http stream, for example, flv/ts/mp3/aac live stream.
*/
// TODO: Support multiple stream.
class SrsHttpStreamServer : virtual public ISrsReloadHandler
, virtual public ISrsHttpMatchHijacker
{