فهرست منبع

Z991239-1954 #comment fix: 解决本地播放音量设置存在失败问题

陈礼鹏80274480 4 سال پیش
والد
کامیت
7079a6759c

+ 8 - 8
Module/mod_interactivecontrol/mod_interactivecontrol.cpp

@@ -1053,7 +1053,6 @@ public:
 			return Error_DevConnFailed;
 		}
 		else {
-#ifdef RVC_OS_WIN
 			PlayService_StartPlayVideo_Req Req;
 			Req.CfgInx = nCfgInx;
 			Req.WndX = nWndX;
@@ -1062,9 +1061,6 @@ public:
 			Req.WndHeight = nWndHeight;
 			CSmartPointer<IAsynWaitSp> spAsyncWait;
 			return pLocalPlayerClient->StartPlayVideo(Req, spAsyncWait, dwTimeout);
-#else
-			return Error_Succeed;
-#endif
 		}
 	}
 
@@ -1113,14 +1109,10 @@ public:
 			return Error_DevConnFailed;
 		}
 		else {
-#ifdef RVC_OS_WIN
 			PlayService_StopPlayVideo_Req Req;
 			Req.CfgInx = nCfgInx;
 			CSmartPointer<IAsynWaitSp> spAsyncWait;
 			return pLocalPlayerClient->StopPlayVideo(Req, spAsyncWait, dwTimeout);
-#else
-			return Error_Succeed;
-#endif
 		}
 	}
 
@@ -1857,9 +1849,13 @@ void UIServiceSession::Handle_StopPhotograph(SpOnewayCallContext<UIService_StopP
 // add by ly
 void UIServiceSession::Handle_StartPlayVideo(SpReqAnsContext<UIService_StartPlayVideo_Req, UIService_StartPlayVideo_Ans>::Pointer ctx)
 {
+#ifdef RVC_OS_WIN
 	ErrorCodeEnum Error = m_pEntity->StartPlayVideo(ctx->Req.CfgInx, ctx->Req.WndX, ctx->Req.WndY, ctx->Req.WndWidth, ctx->Req.WndHeight, 800);
 	Dbg("Start Play Local Video!");
 	ctx->Answer(Error);
+#else
+	ctx->Answer(Error_Succeed);
+#endif
 }
 
 void UIServiceSession::Handle_StartPlayAudio(SpReqAnsContext<UIService_StartPlayAudio_Req, UIService_StartPlayAudio_Ans>::Pointer ctx)
@@ -1878,9 +1874,13 @@ void UIServiceSession::Handle_StartPlayImage(SpReqAnsContext<UIService_StartPlay
 
 void UIServiceSession::Handle_StopPlayVideo(SpReqAnsContext<UIService_StopPlayVideo_Req, UIService_StopPlayVideo_Ans>::Pointer ctx)
 {
+#ifdef RVC_OS_WIN
 	ErrorCodeEnum Error = m_pEntity->StopPlayVideo(ctx->Req.CfgInx, 800);
 	Dbg("Stop Play Local Video!");
 	ctx->Answer(Error);
+#else
+	ctx->Answer(Error_Succeed);
+#endif
 }
 
 void UIServiceSession::Handle_StopPlayAudio(SpReqAnsContext<UIService_StopPlayAudio_Req, UIService_StopPlayAudio_Ans>::Pointer ctx)

+ 2 - 0
Module/mod_sipphone/mod_sipphone.cpp

@@ -2437,8 +2437,10 @@ void CSIPPhoneSession::control_video( ControlVideoCommand *pCmd )
 			}
 		}
 		else{
+#ifdef RVC_OS_WIN
 			Dbg("record call remote agent timeout, close video session.");
 			endpoint_call_stop_double_record_broadcast_video();
+#endif
 		}
 	}
 }

+ 0 - 4
Other/libaudioframework/audiomicspkpulse.c

@@ -210,13 +210,9 @@ static void pa_sourcelist_cb(pa_context* c, const pa_source_info* l, int eol, vo
 void finish(pa_context* rvc_pa_ctx, pa_mainloop* pa_ml)
 {
 	/* clean up and disconnect */
-	audio_log_v(AUDIO_LOG_LEVEL_INFO, "%s:%d", __FUNCTION__, __LINE__);
 	pa_context_disconnect(rvc_pa_ctx);
-	audio_log_v(AUDIO_LOG_LEVEL_INFO, "%s:%d", __FUNCTION__, __LINE__);
 	pa_context_unref(rvc_pa_ctx);
-	audio_log_v(AUDIO_LOG_LEVEL_INFO, "%s:%d", __FUNCTION__, __LINE__);
 	pa_mainloop_free(pa_ml);
-	audio_log_v(AUDIO_LOG_LEVEL_INFO, "%s:%d", __FUNCTION__, __LINE__);
 }
 
 

+ 4 - 12
Other/libaudiomgr/libaudiomgr.cpp

@@ -1230,15 +1230,11 @@ static void stream_request_cb(pa_stream* s, size_t length, void* data)
 {
 	rvc_audio_context_t* audio_ctx = (rvc_audio_context_t*)data;
 
-	if (audio_ctx->channels == 0)
-	{
-		printf("AUDIO: (pulse audio) stream_request_cb failed: channels = 0\n");
+	if (audio_ctx->channels == 0){
 		return;
 	}
 
-	if (audio_ctx->samprate == 0)
-	{
-		fprintf(stderr, "AUDIO: (pulse audio) stream_request_cb failed: samprate = 0\n");
+	if (audio_ctx->samprate == 0){
 		return;
 	}
 
@@ -1253,19 +1249,16 @@ static void stream_request_cb(pa_stream* s, size_t length, void* data)
 		size_t length;
 
 		/*read from stream*/
-		if (pa_stream_peek(s, &inputBuffer, &length) < 0)
-		{
-			fprintf(stderr, "AUDIO: (pulseaudio) pa_stream_peek() failed\n");
+		if (pa_stream_peek(s, &inputBuffer, &length) < 0){
 			return;
 		}
 		else {
-			printf("%s:%d pa_stream_peek audio length is %d.\n", __FUNCTION__, __LINE__, length);
+			//printf("%s:%d pa_stream_peek audio length is %d.\n", __FUNCTION__, __LINE__, length);
 		}
 
 
 		if (length == 0)
 		{
-			fprintf(stderr, "AUDIO: (pulse audio) empty buffer!\n");
 			return; /*buffer is empty*/
 		}
 
@@ -1276,7 +1269,6 @@ static void stream_request_cb(pa_stream* s, size_t length, void* data)
 		if (audio_ctx->last_ts <= 0)
 			audio_ctx->last_ts = ts;
 
-
 		uint32_t numSamples = (uint32_t)length / sizeof(sample_t);
 
 		audio_ctx->audio_param.on_audio_callback(inputBuffer, length, audio_ctx->audio_param.user_data);

+ 6 - 1
Other/libmediaplayer/audio.cpp

@@ -481,7 +481,12 @@ static void sdl_audio_callback(void *opaque, Uint8 *stream, int len)
         // 2. 将转换后的音频数据拷贝到音频缓冲区stream中,之后的播放就是音频设备驱动程序的工作了
         if (is->p_audio_frm != NULL){
 			SDL_memset(stream, 0, len1);
-			SDL_MixAudio(stream, (uint8_t*)is->p_audio_frm + is->audio_cp_index, len1, is->uVolume);
+			int ivolume = is->uVolume;
+			if (0 == is->on_audio_volume(&ivolume,is->user_data)){
+				is->rvc_hostapi->Debug(MEDIA_LOG_DEBUG, "on_audio_volume success.");
+			}
+			is->rvc_hostapi->Debug(MEDIA_LOG_DEBUG, "audio uVolume is %d.", ivolume);
+			SDL_MixAudio(stream, (uint8_t*)is->p_audio_frm + is->audio_cp_index, len1, ivolume);
         }
         else{
 			SDL_memset(stream, 0, len1);

+ 2 - 1
Other/libmediaplayer/libmediaplayer.cpp

@@ -323,6 +323,7 @@ public:
 		cb.user_data = this;
 		t_param.cb = &cb;
 
+		m_Player->SetVolume(config.nVolume);
 		if (0 == m_Player->Init(&t_param)) {
 			m_bisplaying = true;
 			m_Player->StartMediaPlay();
@@ -347,7 +348,7 @@ public:
 
 	void SetVolume(int nVolume)
 	{
-		if (m_Player->GetPlayingFlag())
+		//if (m_Player->GetPlayingFlag())
 		{
 			m_Player->SetVolume(nVolume);
 		}

+ 31 - 14
Other/libmediaplayer/player.cpp

@@ -178,7 +178,7 @@ CMediaPlayer::CMediaPlayer(CMediaHostApi* pHostApi)
 {
 	m_hostapi = pHostApi;
 	m_player_stat = NULL;
-	m_uvolume = SDL_MIX_MAXVOLUME;
+	m_uvolume = SDL_MIX_MAXVOLUME/2;
 	m_bplaying = false;
 	m_piconpath = NULL;
 	
@@ -206,6 +206,19 @@ CMediaPlayer::~CMediaPlayer()
 }
 
 
+static int audio_volume_callback(int* audiovolume, void* userdata)
+{
+	CMediaPlayer* player = (CMediaPlayer*)userdata;
+	*audiovolume = player->GetVolume();
+	return 0;
+}
+
+
+uint8_t CMediaPlayer::GetVolume()
+{
+	return m_uvolume;
+}
+
 int CMediaPlayer::Initialize_Player_Stat(rvc_media_player_param_t* pMedia_Player)
 {
 	int iRet = -1;
@@ -231,6 +244,8 @@ int CMediaPlayer::Initialize_Player_Stat(rvc_media_player_param_t* pMedia_Player
 	m_player_stat->bvice_monitor = pMedia_Player->bvicemonitor;
 	m_player_stat->iDisplayCx = pMedia_Player->udisplaycx;
 	m_player_stat->iDisplayCy = pMedia_Player->udisplaycy;
+	m_player_stat->on_audio_volume = &audio_volume_callback;
+	m_player_stat->user_data = this;
 	if (NULL != m_piconpath){
 		m_player_stat->piconpath = av_strdup(m_piconpath);
 	}
@@ -355,19 +370,21 @@ int CMediaPlayer::SetVolume(uint8_t uVolume)
 {
 	int iRet = -1;
 	
-	m_uvolume = uVolume;
-	if (NULL != m_player_stat)
-	{
-		if (GetPlayingFlag())
-		{
-			m_player_stat->uVolume = m_uvolume;
-			iRet = 0;
-		}
-		else 
-		{
-			m_player_stat->rvc_hostapi->Debug(MEDIA_LOG_DEBUG, "set audio volume failed for not in playing status.");
-		}
-	}
+	m_uvolume = uVolume * SDL_MIX_MAXVOLUME/100;
+
+	iRet = 0;
+	//if (NULL != m_player_stat)
+	//{
+	//	if (GetPlayingFlag())
+	//	{
+	//		m_player_stat->uVolume = m_uvolume;
+	//		iRet = 0;
+	//	}
+	//	else 
+	//	{
+	//		m_player_stat->rvc_hostapi->Debug(MEDIA_LOG_DEBUG, "set audio volume failed for not in playing status.");
+	//	}
+	//}
 
 	return iRet;
 }

+ 3 - 0
Other/libmediaplayer/player.h

@@ -218,6 +218,8 @@ typedef struct player_stat_s{
 	int iDisplayCy;
 	int iDisplayWidth;
 	int iDisplayHeight;
+	int (*on_audio_volume)(int* audiodata, void* user_data);
+	void* user_data;
 }player_stat_t;
 
 
@@ -254,6 +256,7 @@ public:
 	int ExitMediaPlayingThread();
 	int64_t GetMediaPlayingThreadId();
 	int GetViceVideoDisplayInfo(int* icx, int* icy, int* iwidth, int* iheight);
+	uint8_t GetVolume();
 
 private:
 	player_stat_t* m_player_stat;

+ 9 - 9
Other/libvideorender/libvideorender.cpp

@@ -157,12 +157,12 @@ int VideoRenderImpl::VideoRenderSetParam(videorender_param_t* tparam)
 		if (SDL_GetRenderDriverInfo(i, rend_info) < 0){
 			m_callback->Debug("Couldn't get SDL2 render driver information: %s", SDL_GetError());
 		}
-		else{
+		else {
 			m_callback->Debug(" %2d: %s", i, rend_info->name);
-			m_callback->Debug("    SDL_RENDERER_TARGETTEXTURE [%c]", (rend_info->flags & SDL_RENDERER_TARGETTEXTURE) ? 'X' : ' ');
-			m_callback->Debug("    SDL_RENDERER_SOFTWARE      [%c]", (rend_info->flags & SDL_RENDERER_SOFTWARE) ? 'X' : ' ');
-			m_callback->Debug("    SDL_RENDERER_ACCELERATED   [%c]", (rend_info->flags & SDL_RENDERER_ACCELERATED) ? 'X' : ' ');
-			m_callback->Debug("    SDL_RENDERER_PRESENTVSYNC  [%c]", (rend_info->flags & SDL_RENDERER_PRESENTVSYNC) ? 'X' : ' ');
+			//m_callback->Debug("    SDL_RENDERER_TARGETTEXTURE [%c]", (rend_info->flags & SDL_RENDERER_TARGETTEXTURE) ? 'X' : ' ');
+			//m_callback->Debug("    SDL_RENDERER_SOFTWARE      [%c]", (rend_info->flags & SDL_RENDERER_SOFTWARE) ? 'X' : ' ');
+			//m_callback->Debug("    SDL_RENDERER_ACCELERATED   [%c]", (rend_info->flags & SDL_RENDERER_ACCELERATED) ? 'X' : ' ');
+			//m_callback->Debug("    SDL_RENDERER_PRESENTVSYNC  [%c]", (rend_info->flags & SDL_RENDERER_PRESENTVSYNC) ? 'X' : ' ');
 		}
 	}
 	free(rend_info);
@@ -203,10 +203,10 @@ int VideoRenderImpl::VideoRenderSetParam(videorender_param_t* tparam)
 		m_callback->Debug("Couldn't get SDL2 rendering driver information: %s", SDL_GetError());
 	}
 	m_callback->Debug("RENDER: rendering driver in use: %s", render_info->name);
-	m_callback->Debug("    SDL_RENDERER_TARGETTEXTURE [%c]", (render_info->flags & SDL_RENDERER_TARGETTEXTURE) ? 'X' : ' ');
-	m_callback->Debug("    SDL_RENDERER_SOFTWARE      [%c]", (render_info->flags & SDL_RENDERER_SOFTWARE) ? 'X' : ' ');
-	m_callback->Debug("    SDL_RENDERER_ACCELERATED   [%c]", (render_info->flags & SDL_RENDERER_ACCELERATED) ? 'X' : ' ');
-	m_callback->Debug("    SDL_RENDERER_PRESENTVSYNC  [%c]", (render_info->flags & SDL_RENDERER_PRESENTVSYNC) ? 'X' : ' ');
+	//m_callback->Debug("    SDL_RENDERER_TARGETTEXTURE [%c]", (render_info->flags & SDL_RENDERER_TARGETTEXTURE) ? 'X' : ' ');
+	//m_callback->Debug("    SDL_RENDERER_SOFTWARE      [%c]", (render_info->flags & SDL_RENDERER_SOFTWARE) ? 'X' : ' ');
+	//m_callback->Debug("    SDL_RENDERER_ACCELERATED   [%c]", (render_info->flags & SDL_RENDERER_ACCELERATED) ? 'X' : ' ');
+	//m_callback->Debug("    SDL_RENDERER_PRESENTVSYNC  [%c]", (render_info->flags & SDL_RENDERER_PRESENTVSYNC) ? 'X' : ' ');
 
 	free(render_info);