mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
change metadata. add hls class.
This commit is contained in:
parent
200a6a6975
commit
4f3cdd51c1
6 changed files with 51 additions and 16 deletions
3
trunk/configure
vendored
Executable file → Normal file
3
trunk/configure
vendored
Executable file → Normal file
|
@ -114,7 +114,8 @@ MODULE_FILES=("srs_core" "srs_core_log" "srs_core_server"
|
||||||
"srs_core_autofree" "srs_core_protocol" "srs_core_amf0"
|
"srs_core_autofree" "srs_core_protocol" "srs_core_amf0"
|
||||||
"srs_core_stream" "srs_core_source" "srs_core_codec"
|
"srs_core_stream" "srs_core_source" "srs_core_codec"
|
||||||
"srs_core_handshake" "srs_core_pithy_print"
|
"srs_core_handshake" "srs_core_pithy_print"
|
||||||
"srs_core_config" "srs_core_refer" "srs_core_reload")
|
"srs_core_config" "srs_core_refer" "srs_core_reload"
|
||||||
|
"srs_core_hls")
|
||||||
MODULE_DIR="src/core" . auto/modules.sh
|
MODULE_DIR="src/core" . auto/modules.sh
|
||||||
CORE_OBJS="${MODULE_OBJS[@]}"
|
CORE_OBJS="${MODULE_OBJS[@]}"
|
||||||
|
|
||||||
|
|
|
@ -36,6 +36,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
#include <srs_core_pithy_print.hpp>
|
#include <srs_core_pithy_print.hpp>
|
||||||
#include <srs_core_config.hpp>
|
#include <srs_core_config.hpp>
|
||||||
#include <srs_core_refer.hpp>
|
#include <srs_core_refer.hpp>
|
||||||
|
#include <srs_core_hls.hpp>
|
||||||
|
|
||||||
#define SRS_PULSE_TIMEOUT_MS 100
|
#define SRS_PULSE_TIMEOUT_MS 100
|
||||||
#define SRS_SEND_TIMEOUT_MS 5000000L
|
#define SRS_SEND_TIMEOUT_MS 5000000L
|
||||||
|
@ -330,6 +331,7 @@ int SrsClient::publish(SrsSource* source, bool is_fmle)
|
||||||
|
|
||||||
SrsPithyPrint pithy_print(SRS_STAGE_PUBLISH_USER);
|
SrsPithyPrint pithy_print(SRS_STAGE_PUBLISH_USER);
|
||||||
|
|
||||||
|
SrsHLS* hls = source->get_hls();
|
||||||
while (true) {
|
while (true) {
|
||||||
// switch to other st-threads.
|
// switch to other st-threads.
|
||||||
st_usleep(0);
|
st_usleep(0);
|
||||||
|
|
|
@ -23,3 +23,11 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
#include <srs_core_hls.hpp>
|
#include <srs_core_hls.hpp>
|
||||||
|
|
||||||
|
SrsHLS::SrsHLS()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
SrsHLS::~SrsHLS()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,4 +29,11 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
#include <srs_core.hpp>
|
#include <srs_core.hpp>
|
||||||
|
|
||||||
|
class SrsHLS
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
SrsHLS();
|
||||||
|
virtual ~SrsHLS();
|
||||||
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
|
@ -30,6 +30,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
#include <srs_core_autofree.hpp>
|
#include <srs_core_autofree.hpp>
|
||||||
#include <srs_core_amf0.hpp>
|
#include <srs_core_amf0.hpp>
|
||||||
#include <srs_core_codec.hpp>
|
#include <srs_core_codec.hpp>
|
||||||
|
#include <srs_core_hls.hpp>
|
||||||
|
|
||||||
#define CONST_MAX_JITTER_MS 500
|
#define CONST_MAX_JITTER_MS 500
|
||||||
#define DEFAULT_FRAME_TIME_MS 10
|
#define DEFAULT_FRAME_TIME_MS 10
|
||||||
|
@ -240,6 +241,7 @@ SrsSource::SrsSource(std::string _stream_url)
|
||||||
{
|
{
|
||||||
stream_url = _stream_url;
|
stream_url = _stream_url;
|
||||||
codec = new SrsCodec();
|
codec = new SrsCodec();
|
||||||
|
hls = new SrsHLS();
|
||||||
|
|
||||||
cache_metadata = cache_sh_video = cache_sh_audio = NULL;
|
cache_metadata = cache_sh_video = cache_sh_audio = NULL;
|
||||||
|
|
||||||
|
@ -265,13 +267,20 @@ SrsSource::~SrsSource()
|
||||||
srs_freep(cache_sh_audio);
|
srs_freep(cache_sh_audio);
|
||||||
|
|
||||||
srs_freep(codec);
|
srs_freep(codec);
|
||||||
|
srs_freep(hls);
|
||||||
|
}
|
||||||
|
|
||||||
|
SrsHLS* SrsSource::get_hls()
|
||||||
|
{
|
||||||
|
return hls;
|
||||||
}
|
}
|
||||||
|
|
||||||
int SrsSource::on_meta_data(SrsCommonMessage* msg, SrsOnMetaDataPacket* metadata)
|
int SrsSource::on_meta_data(SrsCommonMessage* msg, SrsOnMetaDataPacket* metadata)
|
||||||
{
|
{
|
||||||
int ret = ERROR_SUCCESS;
|
int ret = ERROR_SUCCESS;
|
||||||
|
|
||||||
metadata->metadata->set("server", new SrsAmf0String(
|
metadata->metadata->set("server", new SrsAmf0String(RTMP_SIG_SRS_KEY));
|
||||||
|
metadata->metadata->set("srs_server", new SrsAmf0String(
|
||||||
RTMP_SIG_SRS_KEY" "RTMP_SIG_SRS_VERSION" ("RTMP_SIG_SRS_URL_SHORT")"));
|
RTMP_SIG_SRS_KEY" "RTMP_SIG_SRS_VERSION" ("RTMP_SIG_SRS_URL_SHORT")"));
|
||||||
|
|
||||||
SrsAmf0Any* prop = NULL;
|
SrsAmf0Any* prop = NULL;
|
||||||
|
@ -418,6 +427,19 @@ int SrsSource::on_video(SrsCommonMessage* video)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SrsSource::on_unpublish()
|
||||||
|
{
|
||||||
|
clear_gop_cache();
|
||||||
|
|
||||||
|
srs_freep(cache_metadata);
|
||||||
|
video_frame_rate = audio_sample_rate = 0;
|
||||||
|
|
||||||
|
srs_freep(cache_sh_video);
|
||||||
|
srs_freep(cache_sh_audio);
|
||||||
|
|
||||||
|
srs_trace("clear cache/metadata/sequence-headers when unpublish.");
|
||||||
|
}
|
||||||
|
|
||||||
int SrsSource::create_consumer(SrsConsumer*& consumer)
|
int SrsSource::create_consumer(SrsConsumer*& consumer)
|
||||||
{
|
{
|
||||||
int ret = ERROR_SUCCESS;
|
int ret = ERROR_SUCCESS;
|
||||||
|
@ -466,19 +488,6 @@ void SrsSource::on_consumer_destroy(SrsConsumer* consumer)
|
||||||
srs_info("handle consumer destroy success.");
|
srs_info("handle consumer destroy success.");
|
||||||
}
|
}
|
||||||
|
|
||||||
void SrsSource::on_unpublish()
|
|
||||||
{
|
|
||||||
clear_gop_cache();
|
|
||||||
|
|
||||||
srs_freep(cache_metadata);
|
|
||||||
video_frame_rate = audio_sample_rate = 0;
|
|
||||||
|
|
||||||
srs_freep(cache_sh_video);
|
|
||||||
srs_freep(cache_sh_audio);
|
|
||||||
|
|
||||||
srs_trace("clear cache/metadata/sequence-headers when unpublish.");
|
|
||||||
}
|
|
||||||
|
|
||||||
void SrsSource::set_cache(bool enabled)
|
void SrsSource::set_cache(bool enabled)
|
||||||
{
|
{
|
||||||
enable_gop_cache = enabled;
|
enable_gop_cache = enabled;
|
||||||
|
|
|
@ -39,6 +39,7 @@ class SrsSource;
|
||||||
class SrsCommonMessage;
|
class SrsCommonMessage;
|
||||||
class SrsOnMetaDataPacket;
|
class SrsOnMetaDataPacket;
|
||||||
class SrsSharedPtrMessage;
|
class SrsSharedPtrMessage;
|
||||||
|
class SrsHLS;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* the consumer for SrsSource, that is a play client.
|
* the consumer for SrsSource, that is a play client.
|
||||||
|
@ -106,6 +107,7 @@ public:
|
||||||
*/
|
*/
|
||||||
static SrsSource* find(std::string stream_url);
|
static SrsSource* find(std::string stream_url);
|
||||||
private:
|
private:
|
||||||
|
SrsHLS* hls;
|
||||||
SrsCodec* codec;
|
SrsCodec* codec;
|
||||||
std::string stream_url;
|
std::string stream_url;
|
||||||
std::vector<SrsConsumer*> consumers;
|
std::vector<SrsConsumer*> consumers;
|
||||||
|
@ -143,14 +145,20 @@ private:
|
||||||
public:
|
public:
|
||||||
SrsSource(std::string _stream_url);
|
SrsSource(std::string _stream_url);
|
||||||
virtual ~SrsSource();
|
virtual ~SrsSource();
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
* get the hls handler, which has a long lifecycle
|
||||||
|
* util the source destroyed.
|
||||||
|
*/
|
||||||
|
virtual SrsHLS* get_hls();
|
||||||
public:
|
public:
|
||||||
virtual int on_meta_data(SrsCommonMessage* msg, SrsOnMetaDataPacket* metadata);
|
virtual int on_meta_data(SrsCommonMessage* msg, SrsOnMetaDataPacket* metadata);
|
||||||
virtual int on_audio(SrsCommonMessage* audio);
|
virtual int on_audio(SrsCommonMessage* audio);
|
||||||
virtual int on_video(SrsCommonMessage* video);
|
virtual int on_video(SrsCommonMessage* video);
|
||||||
|
virtual void on_unpublish();
|
||||||
public:
|
public:
|
||||||
virtual int create_consumer(SrsConsumer*& consumer);
|
virtual int create_consumer(SrsConsumer*& consumer);
|
||||||
virtual void on_consumer_destroy(SrsConsumer* consumer);
|
virtual void on_consumer_destroy(SrsConsumer* consumer);
|
||||||
virtual void on_unpublish();
|
|
||||||
virtual void set_cache(bool enabled);
|
virtual void set_cache(bool enabled);
|
||||||
private:
|
private:
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue