mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
Refine typo in app.
This commit is contained in:
parent
4d25520f99
commit
aac8a13f42
15 changed files with 1065 additions and 1962 deletions
|
@ -50,12 +50,10 @@ class SrsTsMessageCache;
|
|||
class SrsHlsSegment;
|
||||
class SrsTsContext;
|
||||
|
||||
/**
|
||||
* the wrapper of m3u8 segment from specification:
|
||||
*
|
||||
* 3.3.2. EXTINF
|
||||
* The EXTINF tag specifies the duration of a media segment.
|
||||
*/
|
||||
// The wrapper of m3u8 segment from specification:
|
||||
//
|
||||
// 3.3.2. EXTINF
|
||||
// The EXTINF tag specifies the duration of a media segment.
|
||||
class SrsHlsSegment : public SrsFragment
|
||||
{
|
||||
public:
|
||||
|
@ -63,7 +61,7 @@ public:
|
|||
int sequence_no;
|
||||
// ts uri in m3u8.
|
||||
std::string uri;
|
||||
// the underlayer file writer.
|
||||
// The underlayer file writer.
|
||||
SrsFileWriter* writer;
|
||||
// The TS context writer to write TS to file.
|
||||
SrsTsContextWriter* tscw;
|
||||
|
@ -78,9 +76,7 @@ public:
|
|||
void config_cipher(unsigned char* key,unsigned char* iv);
|
||||
};
|
||||
|
||||
/**
|
||||
* the hls async call: on_hls
|
||||
*/
|
||||
// The hls async call: on_hls
|
||||
class SrsDvrAsyncCallOnHls : public ISrsAsyncCallTask
|
||||
{
|
||||
private:
|
||||
|
@ -101,9 +97,7 @@ public:
|
|||
virtual std::string to_string();
|
||||
};
|
||||
|
||||
/**
|
||||
* the hls async call: on_hls_notify
|
||||
*/
|
||||
// The hls async call: on_hls_notify
|
||||
class SrsDvrAsyncCallOnHlsNotify : public ISrsAsyncCallTask
|
||||
{
|
||||
private:
|
||||
|
@ -118,14 +112,12 @@ public:
|
|||
virtual std::string to_string();
|
||||
};
|
||||
|
||||
/**
|
||||
* muxer the HLS stream(m3u8 and ts files).
|
||||
* generally, the m3u8 muxer only provides methods to open/close segments,
|
||||
* to flush video/audio, without any mechenisms.
|
||||
*
|
||||
* that is, user must use HlsCache, which will control the methods of muxer,
|
||||
* and provides HLS mechenisms.
|
||||
*/
|
||||
// Mux the HLS stream(m3u8 and ts files).
|
||||
// Generally, the m3u8 muxer only provides methods to open/close segments,
|
||||
// to flush video/audio, without any mechenisms.
|
||||
//
|
||||
// That is, user must use HlsCache, which will control the methods of muxer,
|
||||
// and provides HLS mechenisms.
|
||||
class SrsHlsMuxer
|
||||
{
|
||||
private:
|
||||
|
@ -143,26 +135,26 @@ private:
|
|||
srs_utime_t hls_window;
|
||||
SrsAsyncCallWorker* async;
|
||||
private:
|
||||
// whether use floor algorithm for timestamp.
|
||||
// Whether use floor algorithm for timestamp.
|
||||
bool hls_ts_floor;
|
||||
// the deviation in piece to adjust the fragment to be more
|
||||
// The deviation in piece to adjust the fragment to be more
|
||||
// bigger or smaller.
|
||||
int deviation_ts;
|
||||
// the previous reap floor timestamp,
|
||||
// The previous reap floor timestamp,
|
||||
// used to detect the dup or jmp or ts.
|
||||
int64_t accept_floor_ts;
|
||||
int64_t previous_floor_ts;
|
||||
private:
|
||||
// encrypted or not
|
||||
// Whether encrypted or not
|
||||
bool hls_keys;
|
||||
int hls_fragments_per_key;
|
||||
// key file name
|
||||
// The key file name
|
||||
std::string hls_key_file;
|
||||
// key file path
|
||||
// The key file path
|
||||
std::string hls_key_file_path;
|
||||
// key file url
|
||||
// The key file url
|
||||
std::string hls_key_url;
|
||||
// key and iv.
|
||||
// The key and iv.
|
||||
unsigned char key[16];
|
||||
unsigned char iv[16];
|
||||
SrsFileWriter *writer;
|
||||
|
@ -176,10 +168,8 @@ private:
|
|||
SrsFragmentWindow* segments;
|
||||
// The current writing segment.
|
||||
SrsHlsSegment* current;
|
||||
/**
|
||||
* the ts context, to keep cc continous between ts.
|
||||
* @see https://github.com/ossrs/srs/issues/375
|
||||
*/
|
||||
// The ts context, to keep cc continous between ts.
|
||||
// @see https://github.com/ossrs/srs/issues/375
|
||||
SrsTsContext* context;
|
||||
public:
|
||||
SrsHlsMuxer();
|
||||
|
@ -192,48 +182,32 @@ public:
|
|||
virtual srs_utime_t duration();
|
||||
virtual int deviation();
|
||||
public:
|
||||
/**
|
||||
* initialize the hls muxer.
|
||||
*/
|
||||
// Initialize the hls muxer.
|
||||
virtual srs_error_t initialize();
|
||||
/**
|
||||
* when publish, update the config for muxer.
|
||||
*/
|
||||
// When publish, update the config for muxer.
|
||||
virtual srs_error_t update_config(SrsRequest* r, std::string entry_prefix,
|
||||
std::string path, std::string m3u8_file, std::string ts_file,
|
||||
srs_utime_t fragment, srs_utime_t window, bool ts_floor, double aof_ratio,
|
||||
bool cleanup, bool wait_keyframe, bool keys, int fragments_per_key,
|
||||
std::string key_file, std::string key_file_path, std::string key_url);
|
||||
/**
|
||||
* open a new segment(a new ts file)
|
||||
*/
|
||||
// Open a new segment(a new ts file)
|
||||
virtual srs_error_t segment_open();
|
||||
virtual srs_error_t on_sequence_header();
|
||||
/**
|
||||
* whether segment overflow,
|
||||
* that is whether the current segment duration>=(the segment in config)
|
||||
*/
|
||||
// Whether segment overflow,
|
||||
// that is whether the current segment duration>=(the segment in config)
|
||||
virtual bool is_segment_overflow();
|
||||
/**
|
||||
* whether wait keyframe to reap the ts.
|
||||
*/
|
||||
// Whether wait keyframe to reap the ts.
|
||||
virtual bool wait_keyframe();
|
||||
/**
|
||||
* whether segment absolutely overflow, for pure audio to reap segment,
|
||||
* that is whether the current segment duration>=2*(the segment in config)
|
||||
* @see https://github.com/ossrs/srs/issues/151#issuecomment-71155184
|
||||
*/
|
||||
// Whether segment absolutely overflow, for pure audio to reap segment,
|
||||
// that is whether the current segment duration>=2*(the segment in config)
|
||||
// @see https://github.com/ossrs/srs/issues/151#issuecomment-71155184
|
||||
virtual bool is_segment_absolutely_overflow();
|
||||
public:
|
||||
/**
|
||||
* whether current hls muxer is pure audio mode.
|
||||
*/
|
||||
// Whether current hls muxer is pure audio mode.
|
||||
virtual bool pure_audio();
|
||||
virtual srs_error_t flush_audio(SrsTsMessageCache* cache);
|
||||
virtual srs_error_t flush_video(SrsTsMessageCache* cache);
|
||||
/**
|
||||
* Close segment(ts).
|
||||
*/
|
||||
// Close segment(ts).
|
||||
virtual srs_error_t segment_close();
|
||||
private:
|
||||
virtual srs_error_t do_segment_close();
|
||||
|
@ -242,23 +216,21 @@ private:
|
|||
virtual srs_error_t _refresh_m3u8(std::string m3u8_file);
|
||||
};
|
||||
|
||||
/**
|
||||
* hls stream cache,
|
||||
* use to cache hls stream and flush to hls muxer.
|
||||
*
|
||||
* when write stream to ts file:
|
||||
* video frame will directly flush to M3u8Muxer,
|
||||
* audio frame need to cache, because it's small and flv tbn problem.
|
||||
*
|
||||
* whatever, the Hls cache used to cache video/audio,
|
||||
* and flush video/audio to m3u8 muxer if needed.
|
||||
*
|
||||
* about the flv tbn problem:
|
||||
* flv tbn is 1/1000, ts tbn is 1/90000,
|
||||
* when timestamp convert to flv tbn, it will loose precise,
|
||||
* so we must gather audio frame together, and recalc the timestamp @see SrsTsAacJitter,
|
||||
* we use a aac jitter to correct the audio pts.
|
||||
*/
|
||||
// The hls stream cache,
|
||||
// use to cache hls stream and flush to hls muxer.
|
||||
//
|
||||
// When write stream to ts file:
|
||||
// video frame will directly flush to M3u8Muxer,
|
||||
// audio frame need to cache, because it's small and flv tbn problem.
|
||||
//
|
||||
// Whatever, the Hls cache used to cache video/audio,
|
||||
// and flush video/audio to m3u8 muxer if needed.
|
||||
//
|
||||
// About the flv tbn problem:
|
||||
// flv tbn is 1/1000, ts tbn is 1/90000,
|
||||
// when timestamp convert to flv tbn, it will loose precise,
|
||||
// so we must gather audio frame together, and recalc the timestamp @see SrsTsAacJitter,
|
||||
// we use a aac jitter to correct the audio pts.
|
||||
class SrsHlsController
|
||||
{
|
||||
private:
|
||||
|
@ -278,40 +250,28 @@ public:
|
|||
virtual srs_utime_t duration();
|
||||
virtual int deviation();
|
||||
public:
|
||||
/**
|
||||
* when publish or unpublish stream.
|
||||
*/
|
||||
// When publish or unpublish stream.
|
||||
virtual srs_error_t on_publish(SrsRequest* req);
|
||||
virtual srs_error_t on_unpublish();
|
||||
/**
|
||||
* when get sequence header,
|
||||
* must write a #EXT-X-DISCONTINUITY to m3u8.
|
||||
* @see: hls-m3u8-draft-pantos-http-live-streaming-12.txt
|
||||
* @see: 3.4.11. EXT-X-DISCONTINUITY
|
||||
*/
|
||||
// When get sequence header,
|
||||
// must write a #EXT-X-DISCONTINUITY to m3u8.
|
||||
// @see: hls-m3u8-draft-pantos-http-live-streaming-12.txt
|
||||
// @see: 3.4.11. EXT-X-DISCONTINUITY
|
||||
virtual srs_error_t on_sequence_header();
|
||||
/**
|
||||
* write audio to cache, if need to flush, flush to muxer.
|
||||
*/
|
||||
// write audio to cache, if need to flush, flush to muxer.
|
||||
virtual srs_error_t write_audio(SrsAudioFrame* frame, int64_t pts);
|
||||
/**
|
||||
* write video to muxer.
|
||||
*/
|
||||
// write video to muxer.
|
||||
virtual srs_error_t write_video(SrsVideoFrame* frame, int64_t dts);
|
||||
private:
|
||||
/**
|
||||
* reopen the muxer for a new hls segment,
|
||||
* close current segment, open a new segment,
|
||||
* then write the key frame to the new segment.
|
||||
* so, user must reap_segment then flush_video to hls muxer.
|
||||
*/
|
||||
// Reopen the muxer for a new hls segment,
|
||||
// close current segment, open a new segment,
|
||||
// then write the key frame to the new segment.
|
||||
// so, user must reap_segment then flush_video to hls muxer.
|
||||
virtual srs_error_t reap_segment();
|
||||
};
|
||||
|
||||
/**
|
||||
* Transmux RTMP stream to HLS(m3u8 and ts).
|
||||
* TODO: FIXME: add utest for hls.
|
||||
*/
|
||||
// Transmux RTMP stream to HLS(m3u8 and ts).
|
||||
// TODO: FIXME: add utest for hls.
|
||||
class SrsHls
|
||||
{
|
||||
private:
|
||||
|
@ -338,31 +298,21 @@ public:
|
|||
virtual void dispose();
|
||||
virtual srs_error_t cycle();
|
||||
public:
|
||||
/**
|
||||
* initialize the hls by handler and source.
|
||||
*/
|
||||
// Initialize the hls by handler and source.
|
||||
virtual srs_error_t initialize(SrsOriginHub* h, SrsRequest* r);
|
||||
/**
|
||||
* publish stream event, continue to write the m3u8,
|
||||
* for the muxer object not destroyed.
|
||||
* @param fetch_sequence_header whether fetch sequence from source.
|
||||
*/
|
||||
// Publish stream event, continue to write the m3u8,
|
||||
// for the muxer object not destroyed.
|
||||
// @param fetch_sequence_header whether fetch sequence from source.
|
||||
virtual srs_error_t on_publish();
|
||||
/**
|
||||
* the unpublish event, only close the muxer, donot destroy the
|
||||
* muxer, for when we continue to publish, the m3u8 will continue.
|
||||
*/
|
||||
// The unpublish event, only close the muxer, donot destroy the
|
||||
// muxer, for when we continue to publish, the m3u8 will continue.
|
||||
virtual void on_unpublish();
|
||||
/**
|
||||
* mux the audio packets to ts.
|
||||
* @param shared_audio, directly ptr, copy it if need to save it.
|
||||
*/
|
||||
// Mux the audio packets to ts.
|
||||
// @param shared_audio, directly ptr, copy it if need to save it.
|
||||
virtual srs_error_t on_audio(SrsSharedPtrMessage* shared_audio, SrsFormat* format);
|
||||
/**
|
||||
* mux the video packets to ts.
|
||||
* @param shared_video, directly ptr, copy it if need to save it.
|
||||
* @param is_sps_pps whether the video is h.264 sps/pps.
|
||||
*/
|
||||
// Mux the video packets to ts.
|
||||
// @param shared_video, directly ptr, copy it if need to save it.
|
||||
// @param is_sps_pps whether the video is h.264 sps/pps.
|
||||
// TODO: FIXME: Remove param is_sps_pps.
|
||||
virtual srs_error_t on_video(SrsSharedPtrMessage* shared_video, SrsFormat* format);
|
||||
private:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue