mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
For #299, refine code.
This commit is contained in:
parent
62b7204514
commit
f32aab3d92
175 changed files with 15529 additions and 15935 deletions
|
@ -1,33 +1,29 @@
|
|||
/*
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2013-2017 SRS(ossrs)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
/**
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2013-2017 SRS(ossrs)
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef SRS_APP_HTTP_STREAM_HPP
|
||||
#define SRS_APP_HTTP_STREAM_HPP
|
||||
|
||||
/*
|
||||
#include <srs_app_http_stream.hpp>
|
||||
*/
|
||||
|
||||
#include <srs_core.hpp>
|
||||
|
||||
#include <srs_app_http_conn.hpp>
|
||||
|
@ -38,10 +34,10 @@ class SrsFlvTransmuxer;
|
|||
class SrsTsTransmuxer;
|
||||
|
||||
/**
|
||||
* for the srs http stream cache,
|
||||
* for example, the audio stream cache to make android(weixin) happy.
|
||||
* we start a thread to shrink the queue.
|
||||
*/
|
||||
* for the srs http stream cache,
|
||||
* for example, the audio stream cache to make android(weixin) happy.
|
||||
* we start a thread to shrink the queue.
|
||||
*/
|
||||
class SrsBufferCache : public ISrsEndlessThreadHandler
|
||||
{
|
||||
private:
|
||||
|
@ -64,8 +60,8 @@ public:
|
|||
};
|
||||
|
||||
/**
|
||||
* the stream encoder in some codec, for example, flv or aac.
|
||||
*/
|
||||
* the stream encoder in some codec, for example, flv or aac.
|
||||
*/
|
||||
class ISrsBufferEncoder
|
||||
{
|
||||
public:
|
||||
|
@ -73,33 +69,33 @@ public:
|
|||
virtual ~ISrsBufferEncoder();
|
||||
public:
|
||||
/**
|
||||
* initialize the encoder with file writer(to http response) and stream cache.
|
||||
* @param w the writer to write to http response.
|
||||
* @param c the stream cache for audio stream fast startup.
|
||||
*/
|
||||
* initialize the encoder with file writer(to http response) and stream cache.
|
||||
* @param w the writer to write to http response.
|
||||
* @param c the stream cache for audio stream fast startup.
|
||||
*/
|
||||
virtual int initialize(SrsFileWriter* w, SrsBufferCache* c) = 0;
|
||||
/**
|
||||
* write rtmp video/audio/metadata.
|
||||
*/
|
||||
* write rtmp video/audio/metadata.
|
||||
*/
|
||||
virtual int write_audio(int64_t timestamp, char* data, int size) = 0;
|
||||
virtual int write_video(int64_t timestamp, char* data, int size) = 0;
|
||||
virtual int write_metadata(int64_t timestamp, char* data, int size) = 0;
|
||||
public:
|
||||
/**
|
||||
* for some stream, for example, mp3 and aac, the audio stream,
|
||||
* we use large gop cache in encoder, for the gop cache of SrsSource is ignore audio.
|
||||
* @return true to use gop cache of encoder; otherwise, use SrsSource.
|
||||
*/
|
||||
* for some stream, for example, mp3 and aac, the audio stream,
|
||||
* we use large gop cache in encoder, for the gop cache of SrsSource is ignore audio.
|
||||
* @return true to use gop cache of encoder; otherwise, use SrsSource.
|
||||
*/
|
||||
virtual bool has_cache() = 0;
|
||||
/**
|
||||
* dumps the cache of encoder to consumer.
|
||||
*/
|
||||
* dumps the cache of encoder to consumer.
|
||||
*/
|
||||
virtual int dump_cache(SrsConsumer* consumer, SrsRtmpJitterAlgorithm jitter) = 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* the flv stream encoder, remux rtmp stream to flv stream.
|
||||
*/
|
||||
* the flv stream encoder, remux rtmp stream to flv stream.
|
||||
*/
|
||||
class SrsFlvStreamEncoder : public ISrsBufferEncoder
|
||||
{
|
||||
protected:
|
||||
|
@ -136,8 +132,8 @@ public:
|
|||
#endif
|
||||
|
||||
/**
|
||||
* the ts stream encoder, remux rtmp stream to ts stream.
|
||||
*/
|
||||
* the ts stream encoder, remux rtmp stream to ts stream.
|
||||
*/
|
||||
class SrsTsStreamEncoder : public ISrsBufferEncoder
|
||||
{
|
||||
private:
|
||||
|
@ -156,8 +152,8 @@ public:
|
|||
};
|
||||
|
||||
/**
|
||||
* the aac stream encoder, remux rtmp stream to aac stream.
|
||||
*/
|
||||
* the aac stream encoder, remux rtmp stream to aac stream.
|
||||
*/
|
||||
class SrsAacStreamEncoder : public ISrsBufferEncoder
|
||||
{
|
||||
private:
|
||||
|
@ -177,8 +173,8 @@ public:
|
|||
};
|
||||
|
||||
/**
|
||||
* the mp3 stream encoder, remux rtmp stream to mp3 stream.
|
||||
*/
|
||||
* the mp3 stream encoder, remux rtmp stream to mp3 stream.
|
||||
*/
|
||||
class SrsMp3StreamEncoder : public ISrsBufferEncoder
|
||||
{
|
||||
private:
|
||||
|
@ -198,8 +194,8 @@ public:
|
|||
};
|
||||
|
||||
/**
|
||||
* write stream to http response direclty.
|
||||
*/
|
||||
* write stream to http response direclty.
|
||||
*/
|
||||
class SrsBufferWriter : public SrsFileWriter
|
||||
{
|
||||
private:
|
||||
|
@ -219,9 +215,9 @@ public:
|
|||
};
|
||||
|
||||
/**
|
||||
* the flv live stream supports access rtmp in flv over http.
|
||||
* srs will remux rtmp to flv streaming.
|
||||
*/
|
||||
* the flv live stream supports access rtmp in flv over http.
|
||||
* srs will remux rtmp to flv streaming.
|
||||
*/
|
||||
class SrsLiveStream : public ISrsHttpHandler
|
||||
{
|
||||
private:
|
||||
|
@ -239,8 +235,8 @@ private:
|
|||
};
|
||||
|
||||
/**
|
||||
* the srs live entry
|
||||
*/
|
||||
* the srs live entry
|
||||
*/
|
||||
struct SrsLiveEntry
|
||||
{
|
||||
private:
|
||||
|
@ -260,7 +256,7 @@ public:
|
|||
SrsBufferCache* cache;
|
||||
|
||||
SrsLiveEntry(std::string m);
|
||||
|
||||
|
||||
bool is_flv();
|
||||
bool is_ts();
|
||||
bool is_mp3();
|
||||
|
@ -268,12 +264,12 @@ public:
|
|||
};
|
||||
|
||||
/**
|
||||
* the http stream server instance,
|
||||
* serve http stream, for example, flv/ts/mp3/aac live stream.
|
||||
*/
|
||||
* 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
|
||||
, virtual public ISrsHttpMatchHijacker
|
||||
{
|
||||
private:
|
||||
SrsServer* server;
|
||||
|
@ -288,7 +284,7 @@ public:
|
|||
virtual ~SrsHttpStreamServer();
|
||||
public:
|
||||
virtual int initialize();
|
||||
// http flv/ts/mp3/aac stream
|
||||
// http flv/ts/mp3/aac stream
|
||||
public:
|
||||
virtual int http_mount(SrsSource* s, SrsRequest* r);
|
||||
virtual void http_unmount(SrsSource* s, SrsRequest* r);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue