winlin

refine the mix correct algorithm.

@@ -55,8 +55,8 @@ using namespace std; @@ -55,8 +55,8 @@ using namespace std;
55 // 115 packets is 3s. 55 // 115 packets is 3s.
56 #define SRS_PURE_AUDIO_GUESS_COUNT 115 56 #define SRS_PURE_AUDIO_GUESS_COUNT 115
57 57
58 -// when got these videos or audios, mix ok.  
59 -#define SRS_MIX_CORRECT_MIX_AV 10 58 +// when got these videos or audios, pure audio or video, mix ok.
  59 +#define SRS_MIX_CORRECT_PURE_AV 10
60 60
61 int _srs_time_jitter_string2int(std::string time_jitter) 61 int _srs_time_jitter_string2int(std::string time_jitter)
62 { 62 {
@@ -849,12 +849,25 @@ void SrsMixQueue::push(SrsSharedPtrMessage* msg) @@ -849,12 +849,25 @@ void SrsMixQueue::push(SrsSharedPtrMessage* msg)
849 849
850 SrsSharedPtrMessage* SrsMixQueue::pop() 850 SrsSharedPtrMessage* SrsMixQueue::pop()
851 { 851 {
852 - // when got 10+ videos or audios, mix ok.  
853 - // when got 1 video and 1 audio, mix ok.  
854 - if (nb_videos < SRS_MIX_CORRECT_MIX_AV && nb_audios < SRS_MIX_CORRECT_MIX_AV) {  
855 - if (nb_videos < 1 || nb_audios < 1) {  
856 - return NULL;  
857 - } 852 + bool mix_ok = false;
  853 +
  854 + // pure video
  855 + if (nb_videos >= SRS_MIX_CORRECT_PURE_AV && nb_audios == 0) {
  856 + mix_ok = true;
  857 + }
  858 +
  859 + // pure audio
  860 + if (nb_audios >= SRS_MIX_CORRECT_PURE_AV && nb_videos == 0) {
  861 + mix_ok = true;
  862 + }
  863 +
  864 + // got 1 video and 1 audio, mix ok.
  865 + if (nb_videos >= 1 && nb_audios >= 1) {
  866 + mix_ok = true;
  867 + }
  868 +
  869 + if (!mix_ok) {
  870 + return NULL;
858 } 871 }
859 872
860 // pop the first msg. 873 // pop the first msg.