mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
refine the mix correct algorithm, mix when got 10+ av or got 1 video and 1 audio.
This commit is contained in:
parent
ec24533955
commit
2d9f258eaf
2 changed files with 16 additions and 3 deletions
|
@ -54,6 +54,9 @@ using namespace std;
|
||||||
// 115 packets is 3s.
|
// 115 packets is 3s.
|
||||||
#define SRS_PURE_AUDIO_GUESS_COUNT 115
|
#define SRS_PURE_AUDIO_GUESS_COUNT 115
|
||||||
|
|
||||||
|
// when got these videos or audios, mix ok.
|
||||||
|
#define SRS_MIX_CORRECT_MIX_AV 10
|
||||||
|
|
||||||
int _srs_time_jitter_string2int(std::string time_jitter)
|
int _srs_time_jitter_string2int(std::string time_jitter)
|
||||||
{
|
{
|
||||||
if (time_jitter == "full") {
|
if (time_jitter == "full") {
|
||||||
|
@ -810,6 +813,7 @@ void SrsSource::destroy()
|
||||||
SrsMixQueue::SrsMixQueue()
|
SrsMixQueue::SrsMixQueue()
|
||||||
{
|
{
|
||||||
nb_videos = 0;
|
nb_videos = 0;
|
||||||
|
nb_audios = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
SrsMixQueue::~SrsMixQueue()
|
SrsMixQueue::~SrsMixQueue()
|
||||||
|
@ -827,6 +831,7 @@ void SrsMixQueue::clear()
|
||||||
msgs.clear();
|
msgs.clear();
|
||||||
|
|
||||||
nb_videos = 0;
|
nb_videos = 0;
|
||||||
|
nb_audios = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SrsMixQueue::push(SrsSharedPtrMessage* msg)
|
void SrsMixQueue::push(SrsSharedPtrMessage* msg)
|
||||||
|
@ -835,14 +840,19 @@ void SrsMixQueue::push(SrsSharedPtrMessage* msg)
|
||||||
|
|
||||||
if (msg->is_video()) {
|
if (msg->is_video()) {
|
||||||
nb_videos++;
|
nb_videos++;
|
||||||
|
} else {
|
||||||
|
nb_audios++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SrsSharedPtrMessage* SrsMixQueue::pop()
|
SrsSharedPtrMessage* SrsMixQueue::pop()
|
||||||
{
|
{
|
||||||
// always keep 2+ videos
|
// when got 10+ videos or audios, mix ok.
|
||||||
if (nb_videos < 2) {
|
// when got 1 video and 1 audio, mix ok.
|
||||||
return NULL;
|
if (nb_videos < SRS_MIX_CORRECT_MIX_AV && nb_audios < SRS_MIX_CORRECT_MIX_AV) {
|
||||||
|
if (nb_videos < 1 || nb_audios < 1) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// pop the first msg.
|
// pop the first msg.
|
||||||
|
@ -852,6 +862,8 @@ SrsSharedPtrMessage* SrsMixQueue::pop()
|
||||||
|
|
||||||
if (msg->is_video()) {
|
if (msg->is_video()) {
|
||||||
nb_videos--;
|
nb_videos--;
|
||||||
|
} else {
|
||||||
|
nb_audios--;
|
||||||
}
|
}
|
||||||
|
|
||||||
return msg;
|
return msg;
|
||||||
|
|
|
@ -375,6 +375,7 @@ class SrsMixQueue
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
u_int32_t nb_videos;
|
u_int32_t nb_videos;
|
||||||
|
u_int32_t nb_audios;
|
||||||
std::multimap<int64_t, SrsSharedPtrMessage*> msgs;
|
std::multimap<int64_t, SrsSharedPtrMessage*> msgs;
|
||||||
public:
|
public:
|
||||||
SrsMixQueue();
|
SrsMixQueue();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue