Browse Source

!10279 UOS支持广告播放
Merge pull request !10279 from 80274480/T24IJ231_ST2

杨诗友80174847 1 year ago
parent
commit
632e824a23
74 changed files with 1167 additions and 5575 deletions
  1. 8 7
      Module/include/EventCode.h
  2. 86 78
      Module/mod_facetracking/mod_facetracking.cpp
  3. 14 21
      Module/mod_interactivecontrol/mod_interactivecontrol.cpp
  4. 3 3
      Module/mod_interactivecontrol/mod_interactivecontrol.h
  5. 4 31
      Module/mod_localmediaplay/AdvertManage/BaseFun.cpp
  6. 62 38
      Module/mod_localmediaplay/AdvertManage/MediaManage.cpp
  7. 8 9
      Module/mod_localmediaplay/AdvertManage/mediaManage.h
  8. 4 4
      Module/mod_localmediaplay/CMakeLists.txt
  9. 18 0
      Module/mod_localmediaplay/Event.h
  10. 223 167
      Module/mod_localmediaplay/mod_localmediaplay.cpp
  11. 6 24
      Module/mod_localmediaplay/mod_localmediaplay.h
  12. 10 9
      Module/mod_mediacontroller/Event.h
  13. 9 1
      Module/mod_mediacontroller/capture.cpp
  14. 11 2
      Module/mod_mediacontroller/mod_mediacontroller.cpp
  15. 2 0
      Other/CMakeLists.txt
  16. 1 1
      Other/libmediaplayer/CMakeLists.txt
  17. 129 97
      Other/libmediaplayer/audio.cpp
  18. 0 0
      Other/libmediaplayer/audio.h
  19. 37 34
      Other/libmediaplayer/demux.cpp
  20. 0 0
      Other/libmediaplayer/demux.h
  21. 0 0
      Other/libmediaplayer/frame.cpp
  22. 0 0
      Other/libmediaplayer/frame.h
  23. 3 3
      Other/libmediaplayer/idatastruct.h
  24. 53 191
      Other/libmediaplayer/libmediaplayer.cpp
  25. 0 6
      Other/libmediaplayer/libmediaplayer.h
  26. 5 5
      Other/libmediaplayer/packet.cpp
  27. 0 0
      Other/libmediaplayer/packet.h
  28. 94 80
      Other/libmediaplayer/player.cpp
  29. 48 45
      Other/libmediaplayer/player.h
  30. 90 82
      Other/libmediaplayer/video.cpp
  31. 0 0
      Other/libmediaplayer/video.h
  32. 6 5
      Other/libpictureplayer/CMakeLists.txt
  33. 105 26
      Other/libpictureplayer/CPicturePlayer.cpp
  34. 12 4
      Other/libpictureplayer/CPicturePlayer.h
  35. 1 1
      Other/libpictureplayer/ipicdatastruct.h
  36. 97 22
      Other/libpictureplayer/libpictureplayer.cpp
  37. 0 0
      Other/libpictureplayer/libpictureplayer.h
  38. 0 2
      Other/unix/CMakeLists.txt
  39. 0 73
      Other/unix/libmediaplayer/CMakeLists.txt
  40. 0 533
      Other/unix/libmediaplayer/audio.cpp
  41. 0 200
      Other/unix/libmediaplayer/demux.cpp
  42. 0 84
      Other/unix/libmediaplayer/idatastruct.h
  43. 0 581
      Other/unix/libmediaplayer/libmediaplayer.cpp
  44. 0 54
      Other/unix/libmediaplayer/libmediaplayer.h
  45. 0 11
      Other/unix/libmediaplayer/packet.h
  46. 0 288
      Other/unix/libmediaplayer/player.h
  47. 0 606
      Other/unix/libmediaplayer/video.cpp
  48. 0 55
      Other/unix/libpictureplayer/CMakeLists.txt
  49. 0 326
      Other/unix/libpictureplayer/CPicturePlayer.cpp
  50. 0 99
      Other/unix/libpictureplayer/CPicturePlayer.h
  51. 0 54
      Other/unix/libpictureplayer/ipicdatastruct.h
  52. 0 35
      Other/unix/libpictureplayer/libpictureplayer.h
  53. 0 2
      Other/win/CMakeLists.txt
  54. 1 1
      Other/win/libimgplayer/libimgplayer.h
  55. 0 48
      Other/win/libmediaplayer/ReadMe.txt
  56. 0 6
      Other/win/libmediaplayer/audio.h
  57. 0 6
      Other/win/libmediaplayer/demux.h
  58. 0 19
      Other/win/libmediaplayer/dllmain.cpp
  59. 0 151
      Other/win/libmediaplayer/frame.cpp
  60. 0 18
      Other/win/libmediaplayer/frame.h
  61. 0 156
      Other/win/libmediaplayer/packet.cpp
  62. 0 602
      Other/win/libmediaplayer/player.cpp
  63. 0 8
      Other/win/libmediaplayer/stdafx.cpp
  64. 0 16
      Other/win/libmediaplayer/stdafx.h
  65. 0 8
      Other/win/libmediaplayer/targetver.h
  66. 0 7
      Other/win/libmediaplayer/video.h
  67. 0 48
      Other/win/libpictureplayer/ReadMe.txt
  68. 0 19
      Other/win/libpictureplayer/dllmain.cpp
  69. 0 283
      Other/win/libpictureplayer/libpictureplayer.cpp
  70. 0 8
      Other/win/libpictureplayer/stdafx.cpp
  71. 0 16
      Other/win/libpictureplayer/stdafx.h
  72. 0 8
      Other/win/libpictureplayer/targetver.h
  73. 8 133
      Other/win/libwmpplayer/libwmpplayer.cpp
  74. 9 15
      Other/win/libwmpplayer/libwmpplayer.h

+ 8 - 7
Module/include/EventCode.h

@@ -682,12 +682,13 @@ ERROR_ACCESSAUTH_CONNECT_ACS_x}
 
 
 
-#define LOG_EVT_MOD_ASSISCHAN_STARTED_SUCCESS		0x30C08010	//协助通道实体启动成功	
-#define LOG_EVT_MOD_SIPPHONE_STARTED_SUCCESS		0x30108280	//sipphone 实体启动成功	
-#define LOG_EVT_MOD_SALESRECORDER_STARTED_SUCCESS	0x3151000B	//salesrecorder 实体启动成功	
-#define LOG_EVT_MOD_LOCALPLAYER_STARTED_SUCCESS		0x3130010D	//localplayer 实体启动成功
-#define LOG_EVT_MOD_MEDIACONTROLLER_STARTED_SUCCESS	0x20880078  //mediacontroller 实体启动成功
-
-#define EVENT_MOD_SIP_RESART						0x301A0101	//重启机器
+#define LOG_EVT_MOD_ASSISCHAN_STARTED_SUCCESS				0x30C08010	//协助通道实体启动成功	
+#define LOG_EVT_MOD_SIPPHONE_STARTED_SUCCESS				0x30108280	//sipphone 实体启动成功	
+#define LOG_EVT_MOD_SALESRECORDER_STARTED_SUCCESS			0x3151000B	//salesrecorder 实体启动成功	
+#define LOG_EVT_MOD_LOCALPLAYER_STARTED_SUCCESS				0x3130010D	//localplayer 实体启动成功
+#define LOG_EVT_MOD_MEDIACONTROLLER_STARTED_SUCCESS			0x20890090  //mediacontroller 实体启动成功
+#define LOG_EVT_MOD_FACETRACKING_STARTED_SUCCESS			0x31280009  //facetracking 实体启动成功
+
+#define EVENT_MOD_SIP_RESART								0x301A0101	//重启机器
 
 #endif // __EVENT_CODE_H

+ 86 - 78
Module/mod_facetracking/mod_facetracking.cpp

@@ -23,6 +23,15 @@ using namespace AssistantChannel;
 #define MAX_LOG_LEN 512
 #endif
 
+#ifndef rvc_snprintf
+#ifdef RVC_OS_WIN
+#define rvc_snprintf _snprintf
+#else
+#define rvc_snprintf snprintf
+#endif // RVC_OS_WIN
+
+#endif // rvc_snprintf
+
 // 脸部跟踪&拍照 devel: 0x302
 
 class CFaceTrackingEntity;
@@ -59,24 +68,6 @@ public:
 			return;
 		}
 
-#if 0
-		m_pChannelClient = new ChannelClient(this);
-		Error = m_pChannelClient->Connect();
-		if (Error != Error_Succeed) {
-			m_pChannelClient->SafeDelete();
-			pTransactionContext->SendAnswer(Error); 
-			return;
-		}
-		ChannelService_BeginRecv_Sub Sub;
-		Sub.type = ACM_TYPE_PHT;
-		Error = (*m_pChannelClient)(EntityResource::getLink().upgradeLink())->BeginRecv(Sub);
-		if (Error != Error_Succeed) {
-			m_pChannelClient->GetFunction()->CloseSession();
-			m_pChannelClient = NULL;
-			pTransactionContext->SendAnswer(Error); 
-			return;
-		}
-#endif
 		Error = GetFunction()->RegistSysVarEvent("SessionID", this);
 		if (Error != Error_Succeed) 
 		{
@@ -121,9 +112,15 @@ public:
 		spFunction->SubscribeLog(m_UUid1, this, Log_Event, Severity_None, Error_IgnoreAll, LOG_EVT_HEADLIGHT_GREEN_OFF,NULL,false);
 		spFunction->SubscribeLog(m_UUid2, this, Log_Event, Severity_None, Error_IgnoreAll, LOG_EVT_MEDIACONTROLLER_CAMERA_STARTED,NULL,false);
 		spFunction->SubscribeLog(m_UUid3, this, Log_Event, Severity_None, Error_IgnoreAll, LOG_EVT_MEDIACONTROLLER_CAMERA_STOPPED,NULL,false);
+		spFunction->SubscribeLog(m_UUid4, this, Log_Event, Severity_None, Error_IgnoreAll, LOG_EVT_MEDIACONTROLLER_RESET_ACTIVECAMERA, NULL, false); 
 		pTransactionContext->SendAnswer(Error);
 	}
 
+	virtual void OnStarted()
+	{
+		LogEvent(Severity_Middle, LOG_EVT_MOD_FACETRACKING_STARTED_SUCCESS, "facetracking entity started successfully.");
+	}
+
 	virtual void OnPreClose(EntityCloseCauseEnum eCloseCause,CSmartPointer<ITransactionContext> pTransactionContext) 
 	{ 
 		CSmartPointer<IEntityFunction> spFunction = GetFunction();
@@ -132,6 +129,7 @@ public:
 		spFunction->UnsubscribeLog(m_UUid1);
 		spFunction->UnsubscribeLog(m_UUid2);
 		spFunction->UnsubscribeLog(m_UUid3);
+		spFunction->UnsubscribeLog(m_UUid4);
 		spFunction->UnregistSysVarEvent("SessionID");
 		spFunction->UnregistSysVarEvent("CustomerID");
 		spFunction->UnregistSysVarEvent("CameraState");
@@ -163,63 +161,81 @@ public:
 		const DWORD dwSysError,const DWORD dwUserCode,const DWORD dwEntityInstanceID, const WORD wEntityDevelID, 
 		const CAutoArray<DWORD> &Param, const char *pszEntityName, const char *pszModuleName,const char *pszMessage, const linkContext &pLinkInfo)
 	{
-		if (dwUserCode == LOG_EVT_HEADLIGHT_GREEN_OFF)
+		switch (dwUserCode)
 		{
+		case LOG_EVT_HEADLIGHT_GREEN_OFF:
 			m_facecapture->SetLightChange();
-		}
-		else if (dwUserCode == LOG_EVT_MEDIACONTROLLER_CAMERA_STARTED)
-		{
-			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("recv LOG_EVT_MEDIACONTROLLER_CAMERA_STARTED event");
-			CSimpleStringA strValue;
-			GetFunction()->GetSysVar("CameraState", strValue);
-#if defined(RVC_OS_WIN)
-			int iState = TransCameraStateToInt(strValue[0]);
-			if (3 != iState) {
-				m_facecapture->SetCameraState(iState);
-				m_facecapture->StartFaceCapture();
-			} 
-			else {
-				m_facecapture->SetCameraState(3);
-			}
-#else
-			if (strValue[0] == 'N') {
-				m_facecapture->SetCameraState(0);
-				m_facecapture->StartFaceCapture();
-			}
-			else if (strValue[0]  == 'E')
-			{
-				m_facecapture->SetCameraState(1);
-				m_facecapture->StartFaceCapture();
-			}
-			else if (strValue[0]  == 'O')
+			break;
+
+		case LOG_EVT_MEDIACONTROLLER_CAMERA_STARTED:
 			{
-				m_facecapture->SetCameraState(2);
-				m_facecapture->StartFaceCapture();
+				DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("recv LOG_EVT_MEDIACONTROLLER_CAMERA_STARTED event");
+				CSimpleStringA strValue;
+				GetFunction()->GetSysVar("CameraState", strValue);
+			#if defined(RVC_OS_WIN)
+				int iState = TransCameraStateToInt(strValue[0]);
+				if (3 != iState) {
+					m_facecapture->SetCameraState(iState);
+					m_facecapture->StartFaceCapture();
+				}
+				else {
+					m_facecapture->SetCameraState(3);
+				}
+			#else
+				if (strValue[0] == 'N') {
+					m_facecapture->SetCameraState(0);
+					m_facecapture->StartFaceCapture();
+				}
+				else if (strValue[0] == 'E')
+				{
+					m_facecapture->SetCameraState(1);
+					m_facecapture->StartFaceCapture();
+				}
+				else if (strValue[0] == 'O')
+				{
+					m_facecapture->SetCameraState(2);
+					m_facecapture->StartFaceCapture();
+				}
+				else if (strValue[0] == 'B')
+				{
+					m_facecapture->SetCameraState(3);
+				}
+			#endif //RVC_OS_WIN
+				if (!m_bSingleCamera) {
+					GetFunction()->SetTimer(1, this, 1000);
+				}
 			}
-			else if (strValue[0]  == 'B')
+			break;
+
+		case LOG_EVT_MEDIACONTROLLER_CAMERA_STOPPED:
 			{
-				m_facecapture->SetCameraState(3);
-			}	
-#endif //RVC_OS_WIN
-			if (!m_bSingleCamera) {
-				GetFunction()->SetTimer(1, this, 1000);
-			}
-		}
-		else if (dwUserCode == LOG_EVT_MEDIACONTROLLER_CAMERA_STOPPED)
-		{
-			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("recv LOG_EVT_MEDIACONTROLLER_CAMERA_STOPPED event");
-			
-			m_facecapture->StopFaceCapture();
-			CSimpleStringA strValue;
-			GetFunction()->GetSysVar("CameraState", strValue);
-			int iState = TransCameraStateToInt(strValue[0]);
-			m_facecapture->SetCameraState(iState);
+				DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("recv LOG_EVT_MEDIACONTROLLER_CAMERA_STOPPED event");
+				m_facecapture->StopFaceCapture();
+				CSimpleStringA strValue;
+				GetFunction()->GetSysVar("CameraState", strValue);
+				int iState = TransCameraStateToInt(strValue[0]);
+				m_facecapture->SetCameraState(iState);
 
-			if (!m_bSingleCamera) {
-				GetFunction()->KillTimer(1);
+				if (!m_bSingleCamera) {
+					GetFunction()->KillTimer(1);
+				}
+
+				GetFunction()->SetSysVar(SYSVAR_ACTIVETRACKINGCAMERA, ACTIVETRACKINGCAMERA_ENV); // from Operation -> Environment
 			}
+			break;
 
-			GetFunction()->SetSysVar(SYSVAR_ACTIVETRACKINGCAMERA, ACTIVETRACKINGCAMERA_ENV); // from Operation -> Environment
+		case LOG_EVT_MEDIACONTROLLER_RESET_ACTIVECAMERA:
+			{
+				CSimpleStringA strValue;
+				GetFunction()->GetSysVar(SYSVAR_ACTIVETRACKINGCAMERA, strValue); // E or O
+				if ('O' == strValue[0]) {
+					GetFunction()->SetSysVar(SYSVAR_ACTIVETRACKINGCAMERA, ACTIVETRACKINGCAMERA_ENV); // from Operation -> Environment
+				}
+			}
+			break;
+		default:
+			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("unknown event.");
+			break;
 		}
 	}
 
@@ -319,19 +335,11 @@ public:
 
 			if (((const char*)strCustomerID == NULL)||(_stricmp(strCustomerID,"N") == 0))
 			{
-#ifdef RVC_OS_WIN
-				sprintf(FaceName, "%s\\%s_0", (LPCSTR)strPath, (LPCSTR)strSessionID);
-#else
-				snprintf(FaceName, uLen,"%s%s%s_0", (LPCSTR)strPath, SPLIT_SLASH_STR, strSessionID.GetData());
-#endif // RVC_OS_WIN
+				rvc_snprintf(FaceName, uLen,"%s%s%s_0", strPath.GetData(), SPLIT_SLASH_STR, strSessionID.GetData());
 			}
 			else
 			{
-#ifdef RVC_OS_WIN
-				sprintf(FaceName, "%s\\%s_%s", (LPCSTR)strPath, strSessionID.GetData(), strCustomerID.GetData());
-#else
-				snprintf(FaceName, uLen, "%s%s%s_%s", (LPCSTR)strPath, SPLIT_SLASH_STR, strSessionID.GetData(), strCustomerID.GetData());
-#endif // RVC_OS_WIN
+				rvc_snprintf(FaceName, uLen, "%s%s%s_%s", strPath.GetData(), SPLIT_SLASH_STR, strSessionID.GetData(), strCustomerID.GetData());
 			}
 			bIsSessionChange = false;
 			bIsCustomerChange = false;
@@ -515,7 +523,7 @@ private:
 	}
 
 private:
-	CUUID m_UUid1,m_UUid2,m_UUid3;
+	CUUID m_UUid1,m_UUid2,m_UUid3,m_UUid4;
 	bool bIsSessionChange;
 	bool bIsCustomerChange;
 	CSimpleStringA strCustomerID;

+ 14 - 21
Module/mod_interactivecontrol/mod_interactivecontrol.cpp

@@ -125,18 +125,26 @@ void CITCtrlEntity::OnStarted()
 ErrorCodeEnum CITCtrlEntity::LoadEntityConfig()
 {
 	SpIniMappingTable table;
-	int iRecordMode = 0;
-	table.AddEntryInt("InteractiveControl", "RecordMode", iRecordMode, 0);
+	bool bAdvOffFlag = false;
+	table.AddEntryBoolean("InteractiveControl", "AdvOffFlag", bAdvOffFlag, false);
 
 	CSmartPointer<IConfigInfo> spConfig;
 	ErrorCodeEnum Error = GetFunction()->OpenConfig(Config_CenterSetting, spConfig);
 	if (Error == Error_Succeed) {
 		Error = table.Load(spConfig);
 		if (Error_Succeed == Error){
-			m_iRecordMode = iRecordMode;
+			if (bAdvOffFlag) {
+				m_bAdvOnFlag = false;
+			}
 		}
 	}
 
+	if (eStand2sType != m_eDeviceType) {
+		m_bAdvOnFlag = false;
+	}
+
+	DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("AdvOnFlag:[%s]", m_bAdvOnFlag ? "true" : "false");
+	
 	return Error;
 }
 
@@ -208,21 +216,6 @@ ErrorCodeEnum CITCtrlEntity::__OnStart(ErrorCodeEnum preOperationError)
 			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("register sysvar %s failed!", "CameraState");
 		}
 	}
-	
-
-	if (eStand2sType == m_eDeviceType)
-	{
-		CSmartPointer<IConfigInfo> spConfig;
-		SpIniMappingTable table;
-		ErrorCodeEnum Error = pFunc->OpenConfig(Config_CenterSetting, spConfig);
-		CSimpleStringA strSecondBranch("");
-		if (Error == Error_Succeed){
-			table.AddEntryBoolean("InteractiveControl", "AdvOnFlag", m_bAdvOnFlag, false);
-			table.Load(spConfig);
-		}
-
-		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("AdvOnFlag:[%s]", m_bAdvOnFlag ? "true" : "false");
-	}
 
 	int i = 0;
 	m_arrListener.Init(8);
@@ -615,7 +608,7 @@ ErrorCodeEnum CITCtrlEntity::SendH5SyncData(CSimpleStringW strContent)
 	}
 }
 
-void CITCtrlEntity::SetConnected(BOOL bConnected)
+void CITCtrlEntity::SetConnected(bool bConnected)
 {
 	m_bConnected = bConnected;
 }
@@ -2653,10 +2646,10 @@ void ChannelClient::OnMessage( ErrorCodeEnum Error, ChannelService_State_Info &M
 	if (Error == Error_Succeed) {
 		CITCtrlEntity *pEntity = static_cast<CITCtrlEntity*>(m_pEntityBase);
 		if (Msg.state == eChannelState_Connected) {
-			pEntity->SetConnected(TRUE);
+			pEntity->SetConnected(true);
 			pEntity->SyncMenuTree(1, 1);
 		} else {
-			pEntity->SetConnected(FALSE);
+			pEntity->SetConnected(false);
 		}
 	}
 }

+ 3 - 3
Module/mod_interactivecontrol/mod_interactivecontrol.h

@@ -101,8 +101,8 @@ class CITCtrlEntity : public CEntityBase, public ISysVarListener, public ILogLis
 public:
 	CITCtrlEntity() : m_pChannelClient(NULL), m_pPlayClient(NULL), m_pSalesRecordClient(NULL), m_pSipPhoneClient(NULL), m_pMediaCtlClient(NULL), 
 	m_pRecordClient(NULL), m_bConnected(false), m_bSalesRecording(false),m_bNoticePlaying(false), m_bConnectAssist(false){
-		m_bAdvOnFlag = false;
-		m_iRecordMode = 0;
+		m_bAdvOnFlag = true;
+		m_iRecordMode = 1;
 		m_bRecording = false;
 		m_pConnectClient = NULL;
 	}
@@ -145,7 +145,7 @@ public:
 
 	ErrorCodeEnum SendH5SyncData(CSimpleStringW strContent);
 
-	void SetConnected(BOOL bConnected);
+	void SetConnected(bool bConnected);
 
 	void OnReceivePacket(int type,int sub_type, const char *data, int size);
 

+ 4 - 31
Module/mod_localmediaplay/AdvertManage/BaseFun.cpp

@@ -130,50 +130,23 @@ void split(const string& src, const string& separator, vector<string>& dest)
 
 bool  checkDirExist(const string &strPath)
 {
-#ifdef RVC_OS_WIN
-	WIN32_FIND_DATA  wfd;
-	bool rValue = false;
-	HANDLE hFind = FindFirstFile(strPath.c_str(), &wfd);
-	if ((hFind != INVALID_HANDLE_VALUE) && (wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
-		rValue = true;
-	FindClose(hFind);
-	return rValue;
-#else
-	if (ExistsDir(strPath.c_str()))
-	{
+	if (ExistsDir(strPath.c_str())){
 		return true;
 	}
-	else
-	{
+	else{
 		return false;
 	}
-#endif 
 }
 
 
 bool checkFileExist(string fileName)
 {
-#ifdef RVC_OS_WIN
-	WIN32_FIND_DATA FindFileData;
-	HANDLE hFind;
-
-	hFind = FindFirstFile(fileName.c_str(), &FindFileData);
-
-	if (hFind == INVALID_HANDLE_VALUE)
-		return false;
-
-	FindClose(hFind);
-	return true;
-#else
-	if (ExistsFile(fileName.c_str()))
-	{
+	if (ExistsFile(fileName.c_str())){
 		return true;
 	}
-	else
-	{
+	else{
 		return false;
 	}
-#endif 
 }
 
 

+ 62 - 38
Module/mod_localmediaplay/AdvertManage/MediaManage.cpp

@@ -2,7 +2,7 @@
 #include "mediaManage.h"
 #include <set>
 #include <algorithm>
-
+#include "../Event.h"
 
 mediaManage::mediaManage()
 {
@@ -19,7 +19,7 @@ mediaManage::mediaManage()
 		setDefaultAddvertPath(string(DEFAULT_RESOURSE_PATH_C));
 		setDefaultDownloadPath(string(DEFAULT_DOWNLOAD_PATH_C));
 	}
-	bloged = false;
+	m_ilist_size = 0;
 }
 
 void mediaManage::setDefaultAddvertPath(string addvertPath){ m_addvertPath = addvertPath; }
@@ -38,9 +38,9 @@ void mediaManage::GetPlayList(vector<ResourceParse> &resourceList)
 	}
 }
 
-size_t mediaManage::GetPlayListByLocal(vector<ResourceParse>& resourceList)
+int mediaManage::GetPlayListByLocal(vector<ResourceParse>& resourceList)
 {
-	size_t uNum = 0;
+	int iNum = 0;
 	resourceList.clear();
 
 #ifdef RVC_OS_WIN
@@ -48,7 +48,7 @@ size_t mediaManage::GetPlayListByLocal(vector<ResourceParse>& resourceList)
 	{
 		if (checkInVaildTime(i.vaildTime, true) && checkInPlayTime(i.playTime, true)) {
 			resourceList.push_back(i);
-			uNum++;
+			iNum++;
 		}
 	}
 #else
@@ -57,10 +57,10 @@ size_t mediaManage::GetPlayListByLocal(vector<ResourceParse>& resourceList)
 		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("play extend %c:%s, %s, %s, %s", it->type, it->resourcePath.c_str(), it->videoNames.c_str(), it->vaildTime.c_str(), it->playTime.c_str());
 		if (checkInVaildTime(it->vaildTime, true) && checkInPlayTime(it->playTime, true)) {
 			resourceList.push_back(*it);
-			uNum++;
+			iNum++;
 		}
 	}
-	DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("uNum is %d, m_localList size is %d, resourceList size is %d", uNum, m_localList.size(), resourceList.size());
+	DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("iNum is %d, m_localList size is %d, resourceList size is %d", iNum, m_localList.size(), resourceList.size());
 
 	for (vector<ResourceParse>::iterator i = resourceList.begin(); i != resourceList.end(); i++)
 	{
@@ -68,15 +68,15 @@ size_t mediaManage::GetPlayListByLocal(vector<ResourceParse>& resourceList)
 	}
 #endif // _WIN32
 
-	return uNum;
+	return iNum;
 }
 
 
-size_t mediaManage::GetPlayListByLocal(CResourceParse** ResourceArr, size_t uSize)
+int mediaManage::GetPlayListByLocal(CResourceParse** ResourceArr, int iSize)
 {
-	size_t uNum = 0;
+	int iNum = 0;
 
-	for (vector<ResourceParse>::iterator it = m_localList.begin(); it != m_localList.end() && uNum < uSize; it++)
+	for (vector<ResourceParse>::iterator it = m_localList.begin(); it != m_localList.end() && iNum < iSize; it++)
 	{
 		//DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("new deep copy play extend %c:%s, %s, %s, %s", it->type, it->resourcePath.c_str(), it->videoNames.c_str(), it->vaildTime.c_str(), it->playTime.c_str());
 		if (checkInVaildTime(it->vaildTime, true) && checkInPlayTime(it->playTime, true)) {
@@ -111,7 +111,7 @@ size_t mediaManage::GetPlayListByLocal(CResourceParse** ResourceArr, size_t uSiz
 				memset(pNode->playTime, 0, it->playTime.length() + 1);
 				memcpy(pNode->playTime, it->playTime.c_str(), it->playTime.length());
 			}
-			ResourceArr[uNum++] = pNode;
+			ResourceArr[iNum++] = pNode;
 			//DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("aftercopy play extend pNode->type=0x%08x:pNode->presourcePath=0x%08x, pNode->pvideoNames=0x%08x, pNode->pvaildTime=0x%08x, pNode->playTime=0x%08x", pNode->type, pNode->presourcePath, pNode->pvideoNames, pNode->pvaildTime, pNode->playTime);
 			//DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("aftercopy play extend %c:%s, %s, %s, %s", pNode->type, pNode->presourcePath, pNode->pvideoNames, pNode->pvaildTime, pNode->playTime);
 			//DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("%s:%d    ResourceList[%d] address is 0x%08x, pNode address is 0x%08x.", __FUNCTION__, __LINE__, uNum-1, ResourceArr[uNum-1], pNode);
@@ -119,21 +119,18 @@ size_t mediaManage::GetPlayListByLocal(CResourceParse** ResourceArr, size_t uSiz
 		}
 	}
 
-	return uNum;
+	return iNum;
 }
 
 
-size_t mediaManage::GetPlayListByLocal(rvcResourceParse_t* ResourceArr, size_t uSize)
+int mediaManage::GetPlayListByLocal(rvcResourceParse_t* ResourceArr, int iSize)
 {
-	size_t uNum = 0;
+	int iNum = 0;
 
-	for (vector<ResourceParse>::iterator it = m_localList.begin(); it != m_localList.end() && uNum < uSize; it++)
+	for (vector<ResourceParse>::iterator it = m_localList.begin(); it != m_localList.end() && iNum < iSize; it++)
 	{
-		if (false == bloged){
-			//DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("new deep copy play extend %c:%s, %s, %s, %s", it->type, it->resourcePath.c_str(), it->videoNames.c_str(), it->vaildTime.c_str(), it->playTime.c_str());
-		}
 		if (checkInVaildTime(it->vaildTime, true) && checkInPlayTime(it->playTime, true) && IsResourceExist(it->resourcePath, it->videoNames)) {
-			rvcResourceParse_t* pNode = ResourceArr+uNum;
+			rvcResourceParse_t* pNode = ResourceArr+iNum;
 			pNode->type = it->type;
 			pNode->fullScreen = it->fullScreen;
 			pNode->primMonitor = it->primMonitor;
@@ -156,12 +153,11 @@ size_t mediaManage::GetPlayListByLocal(rvcResourceParse_t* ResourceArr, size_t u
 			if (it->playTime.length() > 0) {
 				memcpy(pNode->strplayTime, it->playTime.c_str(), it->playTime.length());
 			}
-			uNum++;
+			iNum++;
 		}
 	}
-	bloged = true;
 
-	return uNum;
+	return iNum;
 }
 
 
@@ -261,14 +257,14 @@ void mediaManage::InitResourceListByLocal()
 	vector<ResourceParse> headList, branchList, networkList, allList;
 
 	if (!checkFileExist(headFile)) {
-		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("head config %s not exist!", headFile.c_str());
+		DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("head config %s not exist!", headFile.c_str());
 	}
 	else if (!parseResourceIni(headFile.c_str(), headList)) {
 		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("parse head config %s fail!", headFile.c_str());
 	}
 
 	if (!checkFileExist(branchFile)) {
-		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("branch config %s not exist!", branchFile.c_str());
+		DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("branch config %s not exist!", branchFile.c_str());
 	}
 	else if (!parseResourceIni(branchFile.c_str(), branchList)) {
 		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("parse branch config %s fail!", branchFile.c_str());
@@ -276,24 +272,36 @@ void mediaManage::InitResourceListByLocal()
 
 
 	if (!checkFileExist(networkFile)) {
-		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("network config %s not exist!", networkFile.c_str());
+		DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("network config %s not exist!", networkFile.c_str());
 	}
 	else if (!parseResourceIni(networkFile.c_str(), networkList)) {
 		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("parse network config %s fail!", networkFile.c_str());
 	}
 		
 	m_localList.clear();
+	
+	uint32_t uheadList = 0;
+	uint32_t ubranchList = 0;
+	uint32_t unetworkList = 0;
+	bool blog = false;
+
 #ifdef RVC_OS_WIN
-	for each (auto i in headList)
+	for each (auto i in headList) {
 		m_localList.push_back(i);
-	for each (auto i in branchList)
+		uheadList++;
+	}
+		
+	for each (auto i in branchList) {
 		m_localList.push_back(i);
-	for each (auto i in networkList)
+		ubranchList++;
+	}
+
+	for each (auto i in networkList) {
 		m_localList.push_back(i);
+		unetworkList++;
+	}
+		
 #else
-	size_t uheadList = 0;
-	size_t ubranchList = 0;
-	size_t unetworkList = 0;
 	for (vector<ResourceParse>::iterator it = headList.begin(); it < headList.end(); ++it){
 		m_localList.push_back(*it);
 		uheadList++;
@@ -308,27 +316,43 @@ void mediaManage::InitResourceListByLocal()
 		m_localList.push_back(*it);
 		unetworkList++;
 	}
-	DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("headList size is %d, branchList size is %d, networkList size is %d, and m_localList size is %u.", uheadList, ubranchList, unetworkList, m_localList.size());
-
 #endif // RVC_OS_WIN
-	
+
+	if (m_ilist_size != m_localList.size()) {
+		m_ilist_size = (int)m_localList.size();
+		blog = true;
+		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("adv play list size is %d, head(%d), branch(%d), network(%d).", m_localList.size(), uheadList, ubranchList, unetworkList);
+	}
+
 	std::stable_sort(m_localList.begin(), m_localList.end(), [](const ResourceParse& a, const ResourceParse& b) {
 		return a.priority > b.priority;
 		});
 
-
+	CSimpleStringA strJson("");
+	int index = 0;
 	for (auto i = m_localList.begin(); i != m_localList.end(); i++)
 	{
 		size_t pos = i->videoNames.find("\\");
 		if (pos != string::npos){
-			//Dbg("%s find result is not string::npos", i->videoNames.c_str());
+			DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("%s find result is not string::npos", i->videoNames.c_str());
 			i->resourcePath = m_addvertPath + SPLIT_SLASH_STR + i->videoNames.substr(0, pos) + SPLIT_SLASH_STR;
 			i->videoNames = i->videoNames.substr(pos + 1, i->videoNames.length() - pos - 1);
 		}
 		else {
-			//Dbg("%s find result is string::npos", i->videoNames.c_str());
+			DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("%s find result is string::npos", i->videoNames.c_str());
 			i->resourcePath = m_addvertPath + SPLIT_SLASH_STR;
 		}
+
+		if (blog) {
+			strJson += CSimpleStringA::Format("\"%d\":\"%s\",", index++, i->videoNames.c_str());
+		}
+	}
+
+	if (blog) {
+		if (strJson.GetLength() > 0) {
+			strJson[strJson.GetLength() - 1] = '\0';
+		}
+		LogWarn(Severity_Low, Error_Debug, LOG_EVT_ADV_PLAYLIST_INFO, CSimpleStringA::Format("[{%s}]", strJson.GetData()).GetData());
 	}
 }
 

+ 8 - 9
Module/mod_localmediaplay/AdvertManage/mediaManage.h

@@ -2,10 +2,10 @@
 #include "resourceIniParse.h"
 
 #ifdef RVC_OS_WIN
-#define DEFAULT_DOWNLOAD_PATH	"D:/rvc/Downloads/package"
-#define DEFAULT_RESOURSE_PATH	"D:/rvc/addata/Video"
-#define DEFAULT_DOWNLOAD_PATH_C	"C:/rvc/Downloads/package"
-#define DEFAULT_RESOURSE_PATH_C	"C:/rvc/addata/Video"
+#define DEFAULT_DOWNLOAD_PATH	"D:\\rvc\\Downloads\\package"
+#define DEFAULT_RESOURSE_PATH	"D:\\rvc\\addata\\Video"
+#define DEFAULT_DOWNLOAD_PATH_C	"C:\\rvc\\Downloads\\package"
+#define DEFAULT_RESOURSE_PATH_C	"C:\\rvc\\addata\\Video"
 #else
 #define DEFAULT_DOWNLOAD_PATH	"/opt/rvc/Downloads/package"
 #define DEFAULT_RESOURSE_PATH	"/opt/rvc/adData/Video"
@@ -38,9 +38,9 @@ public:
 	void setDefaultDownloadPath(string downloadPath);
 	bool InitResourseList(vector<string> resourceList);	//初始化资源列表,或者根据资源列表添加删除当前的资源列表
 	void GetPlayList(vector<ResourceParse> &resourceList);
-	size_t GetPlayListByLocal(vector<ResourceParse>& resourceList);
-	size_t GetPlayListByLocal(CResourceParse** ResourceArr, size_t uSize);
-	size_t GetPlayListByLocal(rvcResourceParse_t* ResourceArr, size_t uSize);
+	int GetPlayListByLocal(vector<ResourceParse>& resourceList);
+	int GetPlayListByLocal(CResourceParse** ResourceArr, int iSize);
+	int GetPlayListByLocal(rvcResourceParse_t* ResourceArr, int iSize);
 	
 	void clearOutdataResource();	//定期清理过期资源
 	void InitResourceListByLocal();	//通过本地配置生成资源列表播放
@@ -55,6 +55,5 @@ private:
 	string m_addvertPath, m_downloadPath;
 	vector<ParseInfo> m_curParse;
 	vector<ResourceParse> m_localList;
-	bool bloged;
-
+	int m_ilist_size;
 };

+ 4 - 4
Module/mod_localmediaplay/CMakeLists.txt

@@ -28,18 +28,18 @@ target_link_directories(${MODULE_NAME} PRIVATE
 # 添加实体需要依赖的其他共享库(包括系统库)
 if(WIN32)
 target_include_directories(${MODULE_NAME} PRIVATE
-	${OTHER_LIB_PLATFORM_BASE_DIR}/libmediaplayer
+	${OTHER_LIB_BASE_DIR}/libmediaplayer
 	${OTHER_LIB_PLATFORM_BASE_DIR}/libwmpplayer
 	${OTHER_LIB_PLATFORM_BASE_DIR}/libimgplayer
-	${OTHER_LIB_PLATFORM_BASE_DIR}/libpictureplayer
+	${OTHER_LIB_BASE_DIR}/libpictureplayer
 	${OTHER_LIB_PLATFORM_BASE_DIR}/libaudioqueue
 	${OTHER_LIB_PLATFORM_BASE_DIR}/rvcmediacommon
 )
 set(${MODULE_PREFIX}_LIBS  ${MODULE_BASE_LIBS} ${RVCCOMM_LIB} ShLwApi Shell32 imgplayer wmpplayer mediaplayer audioqueue pictureplayer)
 else(WIN32)
 target_include_directories(${MODULE_NAME} PRIVATE
-	${OTHER_LIB_PLATFORM_BASE_DIR}/libmediaplayer
-	${OTHER_LIB_PLATFORM_BASE_DIR}/libpictureplayer
+	${OTHER_LIB_BASE_DIR}/libmediaplayer
+	${OTHER_LIB_BASE_DIR}/libpictureplayer
 	${OTHER_LIB_PLATFORM_BASE_DIR}/libaudioqueue
 	${OTHER_LIB_PLATFORM_BASE_DIR}/rvcmediacommon
 )

+ 18 - 0
Module/mod_localmediaplay/Event.h

@@ -0,0 +1,18 @@
+#pragma once
+
+#define LOG_EVT_START_NOTICE_PLAY			0x31300101
+#define LOG_EVT_STOP_NOTICE_PLAY			0x31300102
+#define LOG_EVT_NOTICE_PLAY_FINISHED		0x31300103
+#define LOG_EVT_NOTICE_FILE_NOT_EXIST		0x31300104
+
+#define LOG_EVT_ADV_VIDEO_NOT_EXIST			0x31300105
+#define LOG_EVT_ADV_AUDIO_NOT_EXIST			0x31300106
+#define LOG_EVT_ADV_PIC_NOT_EXIST			0x31300107
+
+#define LOG_EVT_VICE_MONITOR_NOT_EXIST		0x31300108
+#define LOG_EVT_VICE_MONITOR_SET_ERROR		0x31300109
+#define LOG_EVT_NOTICE_PLAY_EARLY_TERM		0x3130010A
+#define LOG_EVT_PLAYING_AUDIO_INFOS			0x3130010B
+#define LOG_EVT_NOTICE_FILE_NOT_VALID		0x3130010C
+#define LOG_EVT_MEDIAPLAY_COST_TIME_ERROR	0x3130010D
+#define LOG_EVT_ADV_PLAYLIST_INFO			0x3130010E

File diff suppressed because it is too large
+ 223 - 167
Module/mod_localmediaplay/mod_localmediaplay.cpp


+ 6 - 24
Module/mod_localmediaplay/mod_localmediaplay.h

@@ -32,22 +32,6 @@ using namespace LocalMediaPlay;
 
 #define MAX_PLAY_CHANNELS					3						//最大播放通道数
 
-#define LOG_EVT_START_NOTICE_PLAY			0x31300101
-#define LOG_EVT_STOP_NOTICE_PLAY			0x31300102
-#define LOG_EVT_NOTICE_PLAY_FINISHED		0x31300103
-#define LOG_EVT_NOTICE_FILE_NOT_EXIST		0x31300104
-
-#define LOG_EVT_ADV_VIDEO_NOT_EXIST			0x31300105
-#define LOG_EVT_ADV_AUDIO_NOT_EXIST			0x31300106
-#define LOG_EVT_ADV_PIC_NOT_EXIST			0x31300107
-
-#define LOG_EVT_VICE_MONITOR_NOT_EXIST		0x31300108
-#define LOG_EVT_VICE_MONITOR_SET_ERROR		0x31300109
-#define LOG_EVT_NOTICE_PLAY_EARLY_TERM		0x3130010A
-#define LOG_EVT_PLAYING_AUDIO_INFOS			0x3130010B
-#define LOG_EVT_NOTICE_FILE_NOT_VALID		0x3130010C
-#define LOG_EVT_MEDIAPLAY_COST_TIME_ERROR	0x3130010D
-
 
 #ifndef RVC_AUDIO_LEN
 #define RVC_AUDIO_LEN 320
@@ -101,9 +85,9 @@ public:
 	virtual DeviceTypeEnum RvcGetDeviceType();
 	
 #ifdef RVC_OS_WIN
-	virtual BOOL LoadPlayConfig(CWmpPlayConfig& config, int CfgInx);
+	virtual bool LoadPlayConfig(CWmpPlayConfig& config, int CfgInx);
 
-	virtual BOOL LoadPlayConfig(CImgPlayConfig& config, int CfgInx);
+	virtual bool LoadPlayConfig(CImgPlayConfig& config, int CfgInx);
 
 	virtual void WmpDebug(const char* fmt, ...);
 
@@ -121,11 +105,11 @@ public:
 
 	virtual void MediaPlayFinished(int iMediaType);
 
-	virtual int GetMediaPlayerIcoPath(char* strPath, size_t uLen);
+	virtual int GetMediaPlayerIcoPath(char* strPath, int uLen);
 
-	virtual int GetPicPlayerIcoPath(char* strPath, size_t uLen);
+	virtual int GetPicPlayerIcoPath(char* strPath, int uLen);
 
-	virtual int GetAudioOutDevName(char* strDev, size_t uLen);
+	virtual int GetAudioOutDevName(char* strDev, int uLen);
 
 	virtual int PlayingAudioDataCallback(audio_param_t* param, const void* input, unsigned long uaudiolen);
 
@@ -133,8 +117,6 @@ public:
 
 	bool GetScanExitFlag();
 
-	ErrorCodeEnum GetPcmRecordFlag();
-
 	ErrorCodeEnum HandleRemoteRecord(const char* pszMessage);	
 
 	virtual void OnLog(const CAutoArray<CUUID> &SubIDs, const CUUID nLogID, const LogTypeEnum eLogType, const SeverityLevelEnum eLevel,
@@ -240,7 +222,7 @@ private:
 
 	void loadDefaultMedia(bool fNewVersion = true);
 
-	int GetPlayerIcoPath(char* strPath, size_t uLen);
+	int GetPlayerIcoPath(char* strPath, int iLen);
 
 	int GetAudioOutDev();
 

+ 10 - 9
Module/mod_mediacontroller/Event.h

@@ -30,23 +30,24 @@
 #define ERROR_MOD_MEDIACONTROLLER_ENVCAMERA_VAGUE			0x20880023  //环境摄像头模糊,级别2
 #define ERROR_MOD_MEDIACONTROLLER_OPECAMERAL_VAGUE			0x20880024  //操作摄像头模糊,级别2
 
-#define ERROR_MOD_MEDIACONTROLLER_ENVCAM_OPEN				0x20880042  //环境摄像头打开失败,级别3
-#define ERROR_MOD_MEDIACONTROLLER_OPTCAM_OPEN				0x20880043  //操作摄像头打开失败,级别3
-#define ERROR_MOD_MEDIACONTROLLER_ENVCAM_INITFAIL			0x20880046  //环境摄像头初始化失败,级别3
-#define ERROR_MOD_MEDIACONTROLLER_OPTCAM_INITFAIL			0x20880047  //操作摄像头初始化失败,级别3
-
-#define ERROR_MOD_MEDIACONTROLLER_CONFIG_ALLERROR			0x20880050  //配置的摄像头都故障
-
-
 #define ERROR_MOD_MEDIACONTROLLER_RECORD_DISKFULL			0x20880031  //录像磁盘满,级别2
 #define ERROR_MOD_MEDIACONTROLLER_RECORD_WRITEFAIL			0x20880032  //录像写入失败,级别3
 
 //warning
 #define ERROR_MOD_MEDIACONTROLLER_HANDFREE_OPENFAIL			0x20880041  //打开免提失败,级别3	
+
+#define ERROR_MOD_MEDIACONTROLLER_ENVCAM_OPEN				0x20880042  //环境摄像头打开失败,级别3
+#define ERROR_MOD_MEDIACONTROLLER_OPTCAM_OPEN				0x20880043  //操作摄像头打开失败,级别3
+
 //warning
 #define ERROR_MOD_MEDIACONTROLLER_HANDFREEIN_INITFAIL		0x20880044  //免提初始化失败,级别3
 #define ERROR_MOD_MEDIACONTROLLER_HANDFREEOUT_INITFAIL		0x20880045  //免提初始化失败,级别3
 
+#define ERROR_MOD_MEDIACONTROLLER_ENVCAM_INITFAIL			0x20880046  //环境摄像头初始化失败,级别3
+#define ERROR_MOD_MEDIACONTROLLER_OPTCAM_INITFAIL			0x20880047  //操作摄像头初始化失败,级别3
+
+#define ERROR_MOD_MEDIACONTROLLER_CONFIG_ALLERROR			0x20880050  //配置的摄像头都故障
+
 #define ERROR_MOD_MEDIACONTROLLER_ENV_CAMERA_INFO			0x20880063  //env摄像头信息
 #define ERROR_MOD_MEDIACONTROLLER_OPT_CAMERA_INFO			0x20880064  //opt摄像头信息
 
@@ -68,7 +69,6 @@
 #define LOG_EVT_MEDIACONTROLLER_OPTCAM_CLOSE				0x20880078  //关闭下摄像头
 #define LOG_EVT_MEDIACONTROLLER_CAMOPEN_FAILED_INFO			0x20880079  //摄像头失败原因
 
-#define ERROR_MOD_MEDIACONTROLLER_CONFIG_ALLERROR			0x20880050  //配置的摄像头都故障
 
 
 #define LOG_EVT_MEDIACONTROLLER_CAMERA_STARTED				0x20890001	//摄像头已开启
@@ -77,6 +77,7 @@
 #define LOG_EVT_MEDIACONTROLLER_SETTIMER_ERROR				0x20890003	//设置定时器异常
 #define LOG_EVT_MEDIACONTROLLER_KILLTIMER_ERROR				0x20890004  //停止定时器异常
 
+#define LOG_EVT_MEDIACONTROLLER_RESET_ACTIVECAMERA			0x20890005  //重置active camera变量
 
 //sysvar
 #define SYSVAR_CAMERASTATE	"CameraState"

+ 9 - 1
Module/mod_mediacontroller/capture.cpp

@@ -2022,6 +2022,7 @@ namespace MediaController {
 #else
 		{
 			int inumber = 0;
+			CSimpleStringA strJson("");
 			int icount = rvc_videocap_get_device_count();
 			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("camera count is %d.", icount);
 			for (int i = 0; i < 64 && inumber < icount; ++i) {
@@ -2029,9 +2030,16 @@ namespace MediaController {
 				char strpath[MAX_PATH] = { 0 };
 
 				if (0 == rvc_videocap_get_device_fullpathname(i, strcamera, 2 * MAX_PATH)){
-					DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("%d = %s", inumber++, strcamera);
+					DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("%d = %s", inumber, strcamera);
+					strJson += CSimpleStringA::Format("\"%d\":\"%s\",", inumber, strcamera);
+					inumber++;
 				}
 			}
+
+			if (strJson.GetLength() > 0) {
+				strJson[strJson.GetLength() - 1] = '\0';
+			}
+			LogWarn(Severity_Low, Error_Debug, LOG_EVT_MEDIACONTROLLER_GETCAMERA_INFOS, CSimpleStringA::Format("[{%s}]", strJson.GetData()).GetData());
 		}
 
 #endif // RVC_OS_WIN

+ 11 - 2
Module/mod_mediacontroller/mod_mediacontroller.cpp

@@ -183,7 +183,7 @@ void CMediaControllerEntity::OnPreStart(CAutoArray<CSimpleStringA> strArgs,CSmar
 
 	int i = 0;
 
-	m_arrListener.Init(14);
+	m_arrListener.Init(15);
 	GetFunction()->SubscribeLog(m_arrListener[i++], this, Log_Event, Severity_None, Error_IgnoreAll, MOD_EVENT_SNAPSHOT_START_CAPTURE_ENV);
 	GetFunction()->SubscribeLog(m_arrListener[i++], this, Log_Event, Severity_None, Error_IgnoreAll, MOD_EVENT_SNAPSHOT_START_CAPTURE_OPT);
 	GetFunction()->SubscribeLog(m_arrListener[i++], this, Log_Event, Severity_None, Error_IgnoreAll, MOD_EVENT_SNAPSHOT_START_CAPTURE_ENVOPT);
@@ -198,7 +198,8 @@ void CMediaControllerEntity::OnPreStart(CAutoArray<CSimpleStringA> strArgs,CSmar
 	GetFunction()->SubscribeLog(m_arrListener[i++], this, Log_Event, Severity_None, Error_IgnoreAll, LOG_EVT_MOD_SALESRECORDER_STARTED_SUCCESS, NULL, false);
 	GetFunction()->SubscribeLog(m_arrListener[i++], this, Log_Event, Severity_Middle, Error_IgnoreAll, LOG_EVT_BEGIN_HANDLE_BUSINESS, NULL, false);
 	GetFunction()->SubscribeLog(m_arrListener[i++], this, Log_Event, Severity_Middle, Error_IgnoreAll, LOG_EVT_END_HANDLE_BUSINESS, NULL, false);
-
+	GetFunction()->SubscribeLog(m_arrListener[i++], this, Log_Event, Severity_None, Error_IgnoreAll, LOG_EVT_MOD_FACETRACKING_STARTED_SUCCESS, NULL, false);
+	
 	pTransactionContext->SendAnswer(Error_Succeed);
 }
 
@@ -1396,6 +1397,14 @@ void CMediaControllerEntity::OnLog( const CAutoArray<CUUID> &SubIDs, const CUUID
 		}
 		break;
 
+	case LOG_EVT_MOD_FACETRACKING_STARTED_SUCCESS: 
+		{
+			if (false == m_bStartCamera) {
+				LogEvent(Severity_Middle, LOG_EVT_MEDIACONTROLLER_RESET_ACTIVECAMERA, "reset active camera.");
+			}
+		}
+		break;
+
 	default:
 		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("unknown event.");
 		break;

+ 2 - 0
Other/CMakeLists.txt

@@ -34,6 +34,8 @@ add_subdirectory(libaudiomgr)
 add_subdirectory(liblog4rvcother)
 add_subdirectory(liblog4vendor)
 add_subdirectory(libfilecryption)
+add_subdirectory(libmediaplayer)
+add_subdirectory(libpictureplayer)
 if(MSVC)
    add_subdirectory(win)
 else(MSVC)

+ 1 - 1
Other/win/libmediaplayer/CMakeLists.txt → Other/libmediaplayer/CMakeLists.txt

@@ -18,7 +18,6 @@ set(${MODULE_PREFIX}_SRCS
 	packet.cpp
 	video.h
 	video.cpp
-	dllmain.cpp
 )
 
 add_library(${MODULE_NAME} SHARED ${${MODULE_PREFIX}_SRCS})
@@ -52,6 +51,7 @@ target_compile_definitions(${MODULE_NAME} PUBLIC "LIBMEDIAPLAYER_EXPORTS")
 
 deploy_others(${MODULE_PREFIX} ${MODULE_NAME})
 
+# ����Ҫ���������ĵ�������
 if(MSVC)
 set(OTHER_CONAN_DEP_LIBS ${OTHER_CONAN_DEP_LIBS} ${CONAN_BIN_DIRS} PARENT_SCOPE)
 else()

+ 129 - 97
Other/win/libmediaplayer/audio.cpp → Other/libmediaplayer/audio.cpp

@@ -1,7 +1,9 @@
 #include "player.h"
 #include "packet.h"
 #include "frame.h"
+#ifdef _WIN32
 #include "Windows.h"
+#endif
 
 static void sdl_audio_callback(void *opaque, uint8_t*stream, int len);
 
@@ -105,11 +107,11 @@ static int audio_decode_thread(void *arg)
 
 	while (false == is->buser_stop)
     {
-        got_frame = audio_decode_frame(is->p_acodec_ctx[is->iaudio_dec_index], &is->audio_pkt_queue, p_frame, is->rvc_hostapi);
+        got_frame = audio_decode_frame(is->m_pacodec_ctx[is->m_iaudio_dec_index], &is->audio_pkt_queue, p_frame, is->rvc_hostapi);
         if (got_frame < 0){
 			if(-2 == got_frame){
-				if (is->icurrent_index > is->iaudio_dec_index) {
-					is->iaudio_dec_index++;
+				if (is->m_icurrent_index > is->m_iaudio_dec_index) {
+					is->m_iaudio_dec_index++;
 				}
 				continue;
 			}
@@ -121,7 +123,6 @@ static int audio_decode_thread(void *arg)
 
         if (got_frame)
         {
-			//tb = { 1, p_frame->sample_rate };
 			tb.num = 1;
 			tb.den = p_frame->sample_rate;
 			//从frame队列找到一个可写的空间,若未停止则一直等待,已停止时返回NULL
@@ -141,13 +142,12 @@ static int audio_decode_thread(void *arg)
             // 更新音频frame队列大小及写指针
             frame_queue_push(&is->audio_frm_queue);
         }
-		//av_usleep(RVC_DEFAULT_SLEEP_TIME);
     }
 
 the_end:
     av_frame_free(&p_frame);
 	is->rvc_hostapi->Debug(MEDIA_LOG_DEBUG, "audio decode thread exit, thread id is %u, and user stop flag is %s.", SDL_ThreadID(), is->buser_stop ? "true":"false");
-	is->baudio_decode_finished = true;
+	is->m_baudio_decode_finished = true;
 
 	return ret;
 }
@@ -160,14 +160,13 @@ int open_audio_stream(player_stat_t *is)
     int ret = -1;
 
     // 1. 为音频流构建解码器AVCodecContext
-	for (size_t index = 0; index < is->uFilesCount; index++){
+	for (size_t index = 0; index < is->m_uFilesCount; index++){
 		// 1.1 获取解码器参数AVCodecParameters
-
-		p_codec_par = is->p_audio_stream[index]->codecpar;
+		p_codec_par = is->m_paudio_stream[index]->codecpar;
 		// 1.2 获取解码器
 		p_codec = avcodec_find_decoder(p_codec_par->codec_id);
 		if (NULL == p_codec) {
-			is->rvc_hostapi->Debug(MEDIA_LOG_DEBUG, "Cann't find codec!");
+			is->rvc_hostapi->Debug(MEDIA_LOG_ERROR, "Cann't find codec!");
 			return ret;
 		}
 
@@ -175,36 +174,40 @@ int open_audio_stream(player_stat_t *is)
 		// 1.3.1 p_codec_ctx初始化:分配结构体,使用p_codec初始化相应成员为默认值
 		p_codec_ctx = avcodec_alloc_context3(p_codec);
 		if (p_codec_ctx == NULL) {
-			is->rvc_hostapi->Debug(MEDIA_LOG_DEBUG, "avcodec_alloc_context3() failed.");
+			is->rvc_hostapi->Debug(MEDIA_LOG_ERROR, "avcodec_alloc_context3() failed.");
 			return ret;
 		}
 		// 1.3.2 p_codec_ctx初始化:p_codec_par ==> p_codec_ctx,初始化相应成员
 		ret = avcodec_parameters_to_context(p_codec_ctx, p_codec_par);
 		if (ret < 0) {
-			is->rvc_hostapi->Debug(MEDIA_LOG_DEBUG, "avcodec_parameters_to_context() failed %d.", ret);
+			is->rvc_hostapi->Debug(MEDIA_LOG_ERROR, "avcodec_parameters_to_context() failed %d.", ret);
+            avcodec_close(p_codec_ctx);
+            avcodec_free_context(&p_codec_ctx);
 			return ret;
 		}
 		// 1.3.3 p_codec_ctx初始化:使用p_codec初始化p_codec_ctx,初始化完成
 		ret = avcodec_open2(p_codec_ctx, p_codec, NULL);
 		if (ret < 0) {
-			is->rvc_hostapi->Debug(MEDIA_LOG_DEBUG, "avcodec_open2() failed %d.", ret);
+			is->rvc_hostapi->Debug(MEDIA_LOG_ERROR, "avcodec_open2() failed %d.", ret);
+            avcodec_close(p_codec_ctx);
+            avcodec_free_context(&p_codec_ctx);
 			return ret;
 		}
 
-		p_codec_ctx->pkt_timebase = is->p_audio_stream[index]->time_base;
-		is->p_acodec_ctx[index] = p_codec_ctx;
+		p_codec_ctx->pkt_timebase = is->m_paudio_stream[index]->time_base;
+		is->m_pacodec_ctx[index] = p_codec_ctx;
 		is->rvc_hostapi->Debug(MEDIA_LOG_DEBUG, "%s:%d is->p_acodec_ctx[%d] = 0x%08x", __FUNCTION__, __LINE__, index, p_codec_ctx);
 	}
 
     // 2. 创建音频解码线程
-	is->audio_decode_tid = SDL_CreateThread(audio_decode_thread, "audio decode thread", is);
-	if (NULL == is->audio_decode_tid) {
+	is->m_audio_decode_tid = SDL_CreateThread(audio_decode_thread, "audio decode thread", is);
+	if (NULL == is->m_audio_decode_tid) {
 		is->rvc_hostapi->Debug(MEDIA_LOG_ERROR, "SDL_Create audio decode thread failed: %s.", SDL_GetError());
 		return -1;
 	}
 	else {
 		ret = 0;
-		is->rvc_hostapi->Debug(MEDIA_LOG_DEBUG, "create %s success, and thread id is %u.", SDL_GetThreadName(is->audio_decode_tid), SDL_GetThreadID(is->audio_decode_tid));
+		is->rvc_hostapi->Debug(MEDIA_LOG_DEBUG, "create %s success, and thread id is %u.", SDL_GetThreadName(is->m_audio_decode_tid), SDL_GetThreadID(is->m_audio_decode_tid));
 	}
 
     return ret;
@@ -219,13 +222,12 @@ static int audio_resample(player_stat_t *is, int64_t audio_callback_time)
     frame_t *af = NULL;
 
     while (frame_queue_nb_remaining(&is->audio_frm_queue) == 0){
-		if ((av_gettime_relative() - audio_callback_time) > 1000000LL * is->audio_hw_buf_size / is->audio_param_tgt.bytes_per_sec / 2) {
+		if ((av_gettime_relative() - audio_callback_time) > 1000000LL * is->audio_hw_buf_size / is->m_audio_param_tgt.bytes_per_sec / 2) {
 			return -1;
 		}
         av_usleep(1000);
     }
 
-	//is->rvc_hostapi->Debug(MEDIA_LOG_DEBUG, "%s:%d.", __FUNCTION__, __LINE__);
     // 若队列头部可读,则由af指向可读帧
 	if (!(af = frame_queue_peek_readable(&is->audio_frm_queue))) {
 		is->rvc_hostapi->Debug(MEDIA_LOG_DEBUG, "%s:%d user stop flag is %s, function return", __FUNCTION__, __LINE__, is->buser_stop ? "true" : "false");
@@ -248,72 +250,72 @@ static int audio_resample(player_stat_t *is, int64_t audio_callback_time)
     // 在audio_open()函数中又有“is->audio_src = is->audio_param_tgt”
     // 此处表示:如果frame中的音频参数 == is->audio_src == is->audio_param_tgt,那音频重采样的过程就免了(因此时is->swr_ctr是NULL)
     //      否则使用frame(源)和is->audio_param_tgt(目标)中的音频参数来设置is->swr_ctx,并使用frame中的音频参数来赋值is->audio_src
-    if (af->frame->format != is->audio_param_src.fmt ||
-        dec_channel_layout != is->audio_param_src.channel_layout ||
-        af->frame->sample_rate != is->audio_param_src.freq)
+    if (af->frame->format != is->m_audio_param_src.fmt ||
+        dec_channel_layout != is->m_audio_param_src.channel_layout ||
+        af->frame->sample_rate != is->m_audio_param_src.freq)
     {
-        swr_free(&is->audio_swr_ctx);
+        swr_free(&is->m_paudio_swr_ctx);
         // 使用frame(源)和is->audio_param_tgt(目标)中的音频参数来设置is->audio_swr_ctx
-        is->audio_swr_ctx = swr_alloc_set_opts(NULL,
-            is->audio_param_tgt.channel_layout, (AVSampleFormat)is->audio_param_tgt.fmt, is->audio_param_tgt.freq,
+        is->m_paudio_swr_ctx = swr_alloc_set_opts(NULL,
+            is->m_audio_param_tgt.channel_layout, (AVSampleFormat)is->m_audio_param_tgt.fmt, is->m_audio_param_tgt.freq,
             dec_channel_layout, (AVSampleFormat)af->frame->format, af->frame->sample_rate,
             0, NULL);
-        if (!is->audio_swr_ctx || swr_init(is->audio_swr_ctx) < 0)
+        if (!is->m_paudio_swr_ctx || swr_init(is->m_paudio_swr_ctx) < 0)
         {
-			is->rvc_hostapi->Debug(MEDIA_LOG_DEBUG, "Cannot create sample rate converter for conversion of %d Hz %s %d channels to %d Hz %s %d channels!",
+			is->rvc_hostapi->Debug(MEDIA_LOG_ERROR, "Cannot create sample rate converter for conversion of %d Hz %s %d channels to %d Hz %s %d channels!",
 				af->frame->sample_rate, av_get_sample_fmt_name((AVSampleFormat)af->frame->format), af->frame->channels,
-				is->audio_param_tgt.freq, av_get_sample_fmt_name((AVSampleFormat)is->audio_param_tgt.fmt), is->audio_param_tgt.channels);
-            swr_free(&is->audio_swr_ctx);
+				is->m_audio_param_tgt.freq, av_get_sample_fmt_name((AVSampleFormat)is->m_audio_param_tgt.fmt), is->m_audio_param_tgt.channels);
+            swr_free(&is->m_paudio_swr_ctx);
             return -1;
         }
         // 使用frame中的参数更新is->audio_src,第一次更新后后面基本不用执行此if分支了,因为一个音频流中各frame通用参数一样
-        is->audio_param_src.channel_layout = dec_channel_layout;
-        is->audio_param_src.channels = af->frame->channels;
-        is->audio_param_src.freq = af->frame->sample_rate;
-        is->audio_param_src.fmt = (AVSampleFormat)af->frame->format;
+        is->m_audio_param_src.channel_layout = dec_channel_layout;
+        is->m_audio_param_src.channels = af->frame->channels;
+        is->m_audio_param_src.freq = af->frame->sample_rate;
+        is->m_audio_param_src.fmt = (AVSampleFormat)af->frame->format;
     }
 	
-    if (is->audio_swr_ctx)
+    if (is->m_paudio_swr_ctx)
     {
         // 重采样输入参数1:输入音频样本数是af->frame->nb_samples
         // 重采样输入参数2:输入音频缓冲区
         const uint8_t **in = (const uint8_t **)af->frame->extended_data;
         // 重采样输出参数1:输出音频缓冲区尺寸
         // 重采样输出参数2:输出音频缓冲区
-        uint8_t **out = &is->audio_frm_rwr;
+        uint8_t **out = &is->m_paudio_frm_rwr;
         // 重采样输出参数:输出音频样本数(多加了256个样本)
-        int out_count = (int64_t)wanted_nb_samples * is->audio_param_tgt.freq / af->frame->sample_rate + 256;
+        int out_count = (int64_t)wanted_nb_samples * is->m_audio_param_tgt.freq / af->frame->sample_rate + 256;
         // 重采样输出参数:输出音频缓冲区尺寸(以字节为单位)
-        int out_size = av_samples_get_buffer_size(NULL, is->audio_param_tgt.channels, out_count, (AVSampleFormat)is->audio_param_tgt.fmt, 0);
+        int out_size = av_samples_get_buffer_size(NULL, is->m_audio_param_tgt.channels, out_count, (AVSampleFormat)is->m_audio_param_tgt.fmt, 0);
         int len2 = 0;
         if (out_size < 0){
-			is->rvc_hostapi->Debug(MEDIA_LOG_DEBUG, "av_samples_get_buffer_size() failed.");
+			is->rvc_hostapi->Debug(MEDIA_LOG_ERROR, "av_samples_get_buffer_size() failed.");
             return -1;
         }
-        av_fast_malloc(&is->audio_frm_rwr, &is->audio_frm_rwr_size, out_size);
-		if (!is->audio_frm_rwr) {
+        av_fast_malloc(&is->m_paudio_frm_rwr, &is->audio_frm_rwr_size, out_size);
+		if (!is->m_paudio_frm_rwr) {
 			return AVERROR(ENOMEM);
 		}
         // 音频重采样:返回值是重采样后得到的音频数据中单个声道的样本数
-        len2 = swr_convert(is->audio_swr_ctx, out, out_count, in, af->frame->nb_samples);
+        len2 = swr_convert(is->m_paudio_swr_ctx, out, out_count, in, af->frame->nb_samples);
         if (len2 < 0){
-			is->rvc_hostapi->Debug(MEDIA_LOG_DEBUG, "swr_convert() failed.");
+			is->rvc_hostapi->Debug(MEDIA_LOG_ERROR, "swr_convert() failed.");
             return -1;
         }
 
         if (len2 == out_count){
-			is->rvc_hostapi->Debug(MEDIA_LOG_DEBUG, "audio buffer is probably too small.");
-			if (swr_init(is->audio_swr_ctx) < 0)
-                swr_free(&is->audio_swr_ctx);
+			is->rvc_hostapi->Debug(MEDIA_LOG_ERROR, "audio buffer is probably too small.");
+			if (swr_init(is->m_paudio_swr_ctx) < 0)
+                swr_free(&is->m_paudio_swr_ctx);
         }
-        is->p_audio_frm = is->audio_frm_rwr;
+        is->m_paudio_frm = is->m_paudio_frm_rwr;
         // 重采样返回的一帧音频数据大小(以字节为单位)
-        resampled_data_size = len2 * is->audio_param_tgt.channels * av_get_bytes_per_sample((AVSampleFormat)is->audio_param_tgt.fmt);
+        resampled_data_size = len2 * is->m_audio_param_tgt.channels * av_get_bytes_per_sample((AVSampleFormat)is->m_audio_param_tgt.fmt);
     }
     else
     {
         // 未经重采样,则将指针指向frame中的音频数据
-        is->p_audio_frm = af->frame->data[0];
+        is->m_paudio_frm = af->frame->data[0];
         resampled_data_size = data_size;
     }
 
@@ -341,6 +343,7 @@ static int audio_resample(player_stat_t *is, int64_t audio_callback_time)
     return resampled_data_size;
 }
 
+#ifdef _WIN32
 static char* Utf8ToGB2312(const char* utf8)
 {
 	int len = MultiByteToWideChar(CP_UTF8, 0, utf8, -1, NULL, 0);
@@ -363,6 +366,7 @@ static char* Utf8ToGB2312(const char* utf8)
 	return str;
 }
 
+#endif
 
 static int open_audio_playing(void *arg)
 {
@@ -370,9 +374,9 @@ static int open_audio_playing(void *arg)
 	SDL_AudioSpec wanted_spec = {0};
 	SDL_AudioSpec actual_spec = {0};
 
-    wanted_spec.freq = is->p_acodec_ctx[is->iaudio_dec_index]->sample_rate;   // 采样率
+    wanted_spec.freq = is->m_pacodec_ctx[is->m_iaudio_dec_index]->sample_rate;   // 采样率
     wanted_spec.format = AUDIO_S16SYS;                  // S表带符号,16是采样深度,SYS表采用系统字节序
-    wanted_spec.channels = is->p_acodec_ctx[is->iaudio_dec_index]->channels;  // 声音通道数
+    wanted_spec.channels = is->m_pacodec_ctx[is->m_iaudio_dec_index]->channels;  // 声音通道数
     wanted_spec.silence = 0;                            // 静音值
     // wanted_spec.samples = SDL_AUDIO_BUFFER_SIZE;     // SDL声音缓冲区尺寸,单位是单声道采样点尺寸x通道数
     // SDL声音缓冲区尺寸,单位是单声道采样点尺寸x声道数
@@ -380,42 +384,70 @@ static int open_audio_playing(void *arg)
 	wanted_spec.callback = sdl_audio_callback;          // 回调函数,若为NULL,则应使用SDL_QueueAudio()机制
     wanted_spec.userdata = is;                          // 提供给回调函数的参数
 	
-	if (NULL == is->straudiodev) {
+	if (NULL == is->m_straudiodev) {
+        static bool blog = true;
 		int iaudioapeaker = SDL_GetNumAudioDevices(0);
-		is->rvc_hostapi->Debug(MEDIA_LOG_ERROR, "audio output device number is %d.", iaudioapeaker);
+        if (blog) {
+            is->rvc_hostapi->Debug(MEDIA_LOG_INFO, "audio output device count is %d.", iaudioapeaker);
+        }
+		
 		int i = 0;
 		for (; i < iaudioapeaker; i++) {
+		#ifdef _WIN32
 			char* strdevice = Utf8ToGB2312(SDL_GetAudioDeviceName(i, 0));
-			is->rvc_hostapi->Debug(MEDIA_LOG_ERROR, "device id %d audio device name is %s.", i, strdevice);
-			if (is->paudiodev && strstr(strdevice, is->paudiodev)) {
+            if (blog) {
+                is->rvc_hostapi->Debug(MEDIA_LOG_INFO, "device id %d audio device name is %s.", i, strdevice);
+            }
+			if (is->m_paudiodev && strstr(strdevice, is->m_paudiodev)) {
 				const char* strdevname = SDL_GetAudioDeviceName(i, 0);
-				is->straudiodev = av_strdup(strdevname);
-				is->rvc_hostapi->Debug(MEDIA_LOG_ERROR, "%s matched audio device name is %s.", is->paudiodev, strdevice);
+				is->m_straudiodev = av_strdup(strdevname);
+                if (blog) {
+                    is->rvc_hostapi->Debug(MEDIA_LOG_INFO, "%s matched audio device name is %s.", is->m_paudiodev, strdevice);
+                }
 				delete []strdevice;
 				break;
 			}
-			else {
-				delete[] strdevice;
+            else {
+                delete[] strdevice;
+#else
+            if (blog) {
+                is->rvc_hostapi->Debug(MEDIA_LOG_INFO, "device id %d audio device name is %s.", i, SDL_GetAudioDeviceName(i, 0));
+            }
+            if (is->m_paudiodev && strstr(SDL_GetAudioDeviceName(i, 0), is->m_paudiodev)) {
+                const char* strdevname = SDL_GetAudioDeviceName(i, 0);
+                is->m_straudiodev = av_strdup(strdevname);
+                if (blog) {
+                    is->rvc_hostapi->Debug(MEDIA_LOG_INFO, "%s matched audio device name is %s.", is->m_paudiodev, strdevname);
+                }
+                break;
+			#endif
 			}
 		}
 		if (i == iaudioapeaker) {
-			is->rvc_hostapi->Debug(MEDIA_LOG_ERROR, "matched audio device name (%s) failed!", is->straudiodev ? is->straudiodev : "null");
+			is->rvc_hostapi->Debug(MEDIA_LOG_ERROR, "matched audio device name (%s) failed!", is->m_straudiodev ? is->m_straudiodev : "null");
 		}
 
 		{
 			int inum = SDL_GetNumAudioDrivers();
 			int i = 0;
-			is->rvc_hostapi->Debug(MEDIA_LOG_DEBUG, "Audio Drivers number is %d.", inum);
+            if (blog) {
+                is->rvc_hostapi->Debug(MEDIA_LOG_INFO, "Audio Drivers number is %d.", inum);
+            }
 			for (; i < inum; i++) {
 				const char* drivername = SDL_GetAudioDriver(i);
-				is->rvc_hostapi->Debug(MEDIA_LOG_DEBUG, "[%d] Audio Drivers name is %s.", i, drivername);
+                if (blog) {
+                    is->rvc_hostapi->Debug(MEDIA_LOG_INFO, "[%d] Audio Drivers name is %s.", i, drivername);
+                }
 			}
 		}
-		is->rvc_hostapi->Debug(MEDIA_LOG_ERROR, "current audio driver name is %s.", SDL_GetCurrentAudioDriver());
+        if (blog) {
+            is->rvc_hostapi->Debug(MEDIA_LOG_INFO, "current audio driver name is %s.", SDL_GetCurrentAudioDriver());
+        }
+        blog = false;
 	}
 
-	while (!(audio_dev = SDL_OpenAudioDevice(is->straudiodev, 0, &wanted_spec, &actual_spec, SDL_AUDIO_ALLOW_FREQUENCY_CHANGE | SDL_AUDIO_ALLOW_CHANNELS_CHANGE))){
-		is->rvc_hostapi->Debug(MEDIA_LOG_ERROR, "SDL_OpenAudio (%d channels, %d Hz): %s",wanted_spec.channels, wanted_spec.freq, SDL_GetError());
+	while (!(is->m_audio_dev = SDL_OpenAudioDevice(is->m_straudiodev, 0, &wanted_spec, &actual_spec, SDL_AUDIO_ALLOW_FREQUENCY_CHANGE | SDL_AUDIO_ALLOW_CHANNELS_CHANGE))){
+		is->rvc_hostapi->Debug(MEDIA_LOG_DEBUG, "SDL_OpenAudio (%d channels, %d Hz): %s",wanted_spec.channels, wanted_spec.freq, SDL_GetError());
 		if (!wanted_spec.channels) {
 			if (!wanted_spec.freq) {
 				is->rvc_hostapi->Debug(MEDIA_LOG_ERROR,"No more combinations to try, audio open failed!");
@@ -425,34 +457,34 @@ static int open_audio_playing(void *arg)
 		return -1;
 	}
 
-	is->rvc_hostapi->Debug(MEDIA_LOG_ERROR, "SDL_OpenAudioDevice success and audio_dev is %d.", audio_dev);
-    is->audio_param_tgt.fmt = AV_SAMPLE_FMT_S16;
-    is->audio_param_tgt.freq = actual_spec.freq;
-    is->audio_param_tgt.channel_layout = av_get_default_channel_layout(actual_spec.channels);
-    is->audio_param_tgt.channels = actual_spec.channels;
-    is->audio_param_tgt.frame_size = av_samples_get_buffer_size(NULL, actual_spec.channels, 1, (AVSampleFormat)is->audio_param_tgt.fmt, 1);
-    is->audio_param_tgt.bytes_per_sec = av_samples_get_buffer_size(NULL, actual_spec.channels, actual_spec.freq, (AVSampleFormat)is->audio_param_tgt.fmt, 1);
+	is->rvc_hostapi->Debug(MEDIA_LOG_DEBUG, "SDL_OpenAudioDevice success and audio_dev is %d.", is->m_audio_dev);
+    is->m_audio_param_tgt.fmt = AV_SAMPLE_FMT_S16;
+    is->m_audio_param_tgt.freq = actual_spec.freq;
+    is->m_audio_param_tgt.channel_layout = av_get_default_channel_layout(actual_spec.channels);
+    is->m_audio_param_tgt.channels = actual_spec.channels;
+    is->m_audio_param_tgt.frame_size = av_samples_get_buffer_size(NULL, actual_spec.channels, 1, (AVSampleFormat)is->m_audio_param_tgt.fmt, 1);
+    is->m_audio_param_tgt.bytes_per_sec = av_samples_get_buffer_size(NULL, actual_spec.channels, actual_spec.freq, (AVSampleFormat)is->m_audio_param_tgt.fmt, 1);
 	
-	is->rvc_hostapi->Debug(MEDIA_LOG_ERROR, "audio param target (%d channels, %d Hz, channel_layout(%d), frame_size(%d), bytes_per_sec(%d)).", actual_spec.channels, actual_spec.freq, is->audio_param_tgt.channel_layout, is->audio_param_tgt.frame_size, is->audio_param_tgt.bytes_per_sec);
+	is->rvc_hostapi->Debug(MEDIA_LOG_DEBUG, "audio param target (%d channels, %d Hz, channel_layout(%d), frame_size(%d), bytes_per_sec(%d)).", actual_spec.channels, actual_spec.freq, is->m_audio_param_tgt.channel_layout, is->m_audio_param_tgt.frame_size, is->m_audio_param_tgt.bytes_per_sec);
 
-	if (is->audio_param_tgt.bytes_per_sec <= 0 || is->audio_param_tgt.frame_size <= 0){
-		is->rvc_hostapi->Debug(MEDIA_LOG_DEBUG, "av_samples_get_buffer_size failed.");
-		SDL_CloseAudioDevice(audio_dev);
+	if (is->m_audio_param_tgt.bytes_per_sec <= 0 || is->m_audio_param_tgt.frame_size <= 0){
+		is->rvc_hostapi->Debug(MEDIA_LOG_ERROR, "av_samples_get_buffer_size failed.");
+		SDL_CloseAudioDevice(is->m_audio_dev);
 		return -1;
     }
-    is->audio_param_src = is->audio_param_tgt;
+    is->m_audio_param_src = is->m_audio_param_tgt;
     is->audio_hw_buf_size = actual_spec.size;   // SDL音频缓冲区大小
     is->audio_frm_size = 0;
     is->audio_cp_index = 0;
 
-	SDL_PauseAudioDevice(audio_dev, 0);
+	SDL_PauseAudioDevice(is->m_audio_dev, 0);
 
-	SDL_LockMutex(is->audio_play_wait_mutex);
-	SDL_CondWait(is->audio_play_cond, is->audio_play_wait_mutex);
-	SDL_UnlockMutex(is->audio_play_wait_mutex);
+	SDL_LockMutex(is->m_audio_play_wait_mutex);
+	SDL_CondWait(is->m_audio_play_cond, is->m_audio_play_wait_mutex);
+	SDL_UnlockMutex(is->m_audio_play_wait_mutex);
 
 	is->rvc_hostapi->Debug(MEDIA_LOG_DEBUG, "----------%s:%d before SDL Close Audio Device.", __FUNCTION__, __LINE__);
-	SDL_CloseAudioDevice(audio_dev);
+	SDL_CloseAudioDevice(is->m_audio_dev);
 	is->rvc_hostapi->Debug(MEDIA_LOG_DEBUG, "---------%s:%d after SDL Close Audio Device.", __FUNCTION__, __LINE__);
 
 	return 0;
@@ -471,9 +503,9 @@ static void sdl_audio_callback(void *opaque, uint8_t*stream, int len)
     int audio_size = 0, len1 = 0;
 
 	if (is->buser_stop){
-		SDL_LockMutex(is->audio_play_wait_mutex);
-		SDL_CondSignal(is->audio_play_cond);
-		SDL_UnlockMutex(is->audio_play_wait_mutex);
+		SDL_LockMutex(is->m_audio_play_wait_mutex);
+		SDL_CondSignal(is->m_audio_play_cond);
+		SDL_UnlockMutex(is->m_audio_play_wait_mutex);
 		return;
 	}
 
@@ -485,18 +517,18 @@ static void sdl_audio_callback(void *opaque, uint8_t*stream, int len)
             audio_size = audio_resample(is, audio_callback_time);
 			if (audio_size < 0){
 				if (-1 == audio_size) {
-					if (is->baudio_decode_finished) {
+					if (is->m_baudio_decode_finished) {
 						is->rvc_hostapi->Debug(MEDIA_LOG_DEBUG, "audio_size is -1 sdl_audio_callback return, and set abort flag to true.");
 						is->on_audio_play_finished(is->user_data);
-						SDL_LockMutex(is->audio_play_wait_mutex);
-						SDL_CondSignal(is->audio_play_cond);
-						SDL_UnlockMutex(is->audio_play_wait_mutex);
+						SDL_LockMutex(is->m_audio_play_wait_mutex);
+						SDL_CondSignal(is->m_audio_play_cond);
+						SDL_UnlockMutex(is->m_audio_play_wait_mutex);
 						return;
 					}
 				}
                 /* if error, just output silence */
-                is->p_audio_frm = NULL;
-                is->audio_frm_size = SDL_AUDIO_MIN_BUFFER_SIZE / is->audio_param_tgt.frame_size * is->audio_param_tgt.frame_size;
+                is->m_paudio_frm = NULL;
+                is->audio_frm_size = SDL_AUDIO_MIN_BUFFER_SIZE / is->m_audio_param_tgt.frame_size * is->m_audio_param_tgt.frame_size;
             }
             else{
                 is->audio_frm_size = audio_size;
@@ -510,7 +542,7 @@ static void sdl_audio_callback(void *opaque, uint8_t*stream, int len)
             len1 = len;
         }
         // 2. 将转换后的音频数据拷贝到音频缓冲区stream中,之后的播放就是音频设备驱动程序的工作了
-        if (is->p_audio_frm != NULL){
+        if (is->m_paudio_frm != NULL){
 			SDL_memset(stream, 0, len1);
 			int ivolume = is->uVolume;
 			if (0 == is->on_audio_volume(&ivolume,is->user_data)){
@@ -518,9 +550,9 @@ static void sdl_audio_callback(void *opaque, uint8_t*stream, int len)
 			}
 			//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);
-			SDL_MixAudioFormat(stream, (uint8_t*)is->p_audio_frm + is->audio_cp_index, AUDIO_S16SYS, len1, ivolume);
-			if (is->prvc_cb && is->prvc_cb->cb_playing_audiodata) {
-				is->prvc_cb->cb_playing_audiodata(&(is->audio_param_tgt), (uint8_t*)is->p_audio_frm + is->audio_cp_index, len1, is->prvc_cb->user_data);
+			SDL_MixAudioFormat(stream, (uint8_t*)is->m_paudio_frm + is->audio_cp_index, AUDIO_S16SYS, len1, ivolume);
+			if (is->m_prvc_cb && is->m_prvc_cb->cb_playing_audiodata) {
+				is->m_prvc_cb->cb_playing_audiodata(&(is->m_audio_param_tgt), (uint8_t*)is->m_paudio_frm + is->audio_cp_index, len1, is->m_prvc_cb->user_data);
 			}
         }
         else{
@@ -541,7 +573,7 @@ static void sdl_audio_callback(void *opaque, uint8_t*stream, int len)
         // 更新音频时钟,更新时刻:每次往声卡缓冲区拷入数据后
         // 前面audio_decode_frame中更新的is->audio_clock是以音频帧为单位,所以此处第二个参数要减去未拷贝数据量占用的时间
         set_clock_at(&is->audio_clk,
-            is->audio_clock - (double)(2 * is->audio_hw_buf_size + is->audio_write_buf_size) / is->audio_param_tgt.bytes_per_sec,
+            is->audio_clock - (double)(2 * is->audio_hw_buf_size + is->audio_write_buf_size) / is->m_audio_param_tgt.bytes_per_sec,
             is->audio_clock_serial,
             audio_callback_time / 1000000.0);
     }
@@ -550,7 +582,7 @@ static void sdl_audio_callback(void *opaque, uint8_t*stream, int len)
 int open_audio(player_stat_t *is)
 {
 	is->rvc_hostapi->Debug(MEDIA_LOG_DEBUG, "enter open_audio()");
-	if (-1 == is->audio_idx[is->icurrent_index]){
+	if (-1 == is->audio_idx[is->m_icurrent_index]){
 		is->rvc_hostapi->Debug(MEDIA_LOG_DEBUG, "not find audio stream");
 	}
 	else {

+ 0 - 0
Other/unix/libmediaplayer/audio.h → Other/libmediaplayer/audio.h


+ 37 - 34
Other/win/libmediaplayer/demux.cpp → Other/libmediaplayer/demux.cpp

@@ -15,7 +15,7 @@ static int decode_interrupt_cb(void *ctx)
 static int demux_init(player_stat_t *is)
 {
 	int ret = -1;
-	for (int index = 0; index < is->uFilesCount; index++)
+	for (int index = 0; index < is->m_uFilesCount; index++)
 	{
 		AVFormatContext* p_fmt_ctx = NULL;
 		int err = -1;
@@ -33,16 +33,18 @@ static int demux_init(player_stat_t *is)
 		p_fmt_ctx->interrupt_callback.opaque = is;
 		// 1. 构建AVFormatContext
 		// 1.1 打开视频文件:读取文件头,将文件格式信息存储在"fmt context"中
-		err = avformat_open_input(&p_fmt_ctx, is->strPlayLists[index], NULL, NULL);
+		err = avformat_open_input(&p_fmt_ctx, is->m_strPlayLists[index], NULL, NULL);
 		if (err < 0){
 			char buffer[RVC_MAX_BUFFER_LEN] = { 0 };
 			av_strerror(err, buffer, RVC_MAX_BUFFER_LEN);
-			is->rvc_hostapi->Debug(MEDIA_LOG_ERROR, "avformat_open_input file %s failed %d(%s).", is->strPlayLists[index], err, buffer);
+			is->rvc_hostapi->Debug(MEDIA_LOG_ERROR, "avformat_open_input file %s failed %d(%s).", is->m_strPlayLists[index], err, buffer);
+			avformat_close_input(&p_fmt_ctx);
+			avformat_free_context(p_fmt_ctx);
 			ret = -1;
 			break;
 		}
-		is->p_fmt_ctx[index] = p_fmt_ctx;
-		is->rvc_hostapi->Debug(MEDIA_LOG_DEBUG, "is->p_fmt_ctx[%d] = 0x%08x, p_fmt_ctx = 0x%08x", index, is->p_fmt_ctx[index], p_fmt_ctx);
+		is->m_pfmt_ctx[index] = p_fmt_ctx;
+		is->rvc_hostapi->Debug(MEDIA_LOG_DEBUG, "is->p_fmt_ctx[%d] = 0x%08x, p_fmt_ctx = 0x%08x", index, is->m_pfmt_ctx[index], p_fmt_ctx);
 
 		// 1.2 搜索流信息:读取一段视频文件数据,尝试解码,将取到的流信息填入p_fmt_ctx->streams
 		//     ic->streams是一个指针数组,数组大小是pFormatCtx->nb_streams
@@ -50,7 +52,9 @@ static int demux_init(player_stat_t *is)
 		if (err < 0){
 			char strbuffer[RVC_MAX_BUFFER_LEN] = { 0 };
 			av_strerror(err, strbuffer, RVC_MAX_BUFFER_LEN);
-			is->rvc_hostapi->Debug(MEDIA_LOG_ERROR, "%s avformat_find_stream_info() failed %d(%s).", is->strPlayLists[index], err, strbuffer);
+			is->rvc_hostapi->Debug(MEDIA_LOG_ERROR, "%s avformat_find_stream_info() failed %d(%s).", is->m_strPlayLists[index], err, strbuffer);
+			avformat_close_input(&p_fmt_ctx);
+			avformat_free_context(p_fmt_ctx);
 			ret = -1;
 			break;
 		}
@@ -59,31 +63,32 @@ static int demux_init(player_stat_t *is)
 		for (int i = 0; i < (int)p_fmt_ctx->nb_streams; i++){
 			if ((p_fmt_ctx->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) && (a_idx == -1)){
 				a_idx = i;
-				is->rvc_hostapi->Debug(MEDIA_LOG_DEBUG, "%s Find a audio stream, index %d, media type is %s.", is->strPlayLists[index], a_idx, Media_Type_Table[is->eMType]);
+				is->rvc_hostapi->Debug(MEDIA_LOG_DEBUG, "%s Find a audio stream, index %d, media type is %s.", is->m_strPlayLists[index], a_idx, Media_Type_Table[is->m_eMType]);
 			}
 			if ((p_fmt_ctx->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) && (v_idx == -1)){
 				v_idx = i;
-				is->rvc_hostapi->Debug(MEDIA_LOG_DEBUG, "%s Find a video stream, index %d, media type is %s.", is->strPlayLists[index], v_idx, Media_Type_Table[is->eMType]);
+				is->rvc_hostapi->Debug(MEDIA_LOG_DEBUG, "%s Find a video stream, index %d, media type is %s.", is->m_strPlayLists[index], v_idx, Media_Type_Table[is->m_eMType]);
 			}
 			if (a_idx != -1 && v_idx != -1){
 				break;
 			}
 		}
 
-		if ((a_idx == -1 && v_idx == -1) || (eVideo_Type == is->eMType && v_idx == -1)){
-			is->rvc_hostapi->Debug(MEDIA_LOG_ERROR, "Invalid file %s can not find any audio/video stream.", is->strPlayLists[index]);
+		if ((a_idx == -1 && v_idx == -1) || (eVideo_Type == is->m_eMType && v_idx == -1)){
+			is->rvc_hostapi->Debug(MEDIA_LOG_ERROR, "Invalid file %s can not find any audio/video stream.", is->m_strPlayLists[index]);
 			ret = -1;
 			if (NULL != p_fmt_ctx){
 				avformat_close_input(&p_fmt_ctx);
-				is->p_fmt_ctx[index] = NULL;
+				avformat_free_context(p_fmt_ctx);
+				is->m_pfmt_ctx[index] = NULL;
 			}
 			break;
 		}
 
 		is->audio_idx[index] = a_idx;
 		is->video_idx[index] = v_idx;
-		is->p_audio_stream[index] = p_fmt_ctx->streams[a_idx];
-		is->p_video_stream[index] = p_fmt_ctx->streams[v_idx];
+		is->m_paudio_stream[index] = p_fmt_ctx->streams[a_idx];
+		is->m_pvideo_stream[index] = p_fmt_ctx->streams[v_idx];
 		
 		ret = 0;
 	}
@@ -108,47 +113,45 @@ static int stream_has_enough_packets(AVStream *st, int stream_id, packet_queue_t
 static int demux_thread(void *arg)
 {
     player_stat_t *is = (player_stat_t *)arg;
-    //AVFormatContext *p_fmt_ctx = is->p_fmt_ctx;
     int ret = 0;
     AVPacket pkt1, *pkt = &pkt1;
 
     SDL_mutex *wait_mutex = SDL_CreateMutex();
 
-	is->rvc_hostapi->Debug(MEDIA_LOG_DEBUG, "begin %s av_read_frame, nFilecount is %d. current index is %d.", is->strPlayLists[is->icurrent_index], is->uFilesCount, is->icurrent_index);
+	is->rvc_hostapi->Debug(MEDIA_LOG_DEBUG, "begin %s av_read_frame, nFilecount is %d. current index is %d.", is->m_strPlayLists[is->m_icurrent_index], is->m_uFilesCount, is->m_icurrent_index);
     // 4. 解复用处理
 	while (false == is->buser_stop)
     {
         /* if the queue are full, no need to read more */
         if (is->audio_pkt_queue.packet_queue_size + is->video_pkt_queue.packet_queue_size > MAX_QUEUE_SIZE ||
-            (stream_has_enough_packets(is->p_audio_stream[is->icurrent_index], is->audio_idx[is->icurrent_index], &is->audio_pkt_queue) &&
-             stream_has_enough_packets(is->p_video_stream[is->icurrent_index], is->video_idx[is->icurrent_index], &is->video_pkt_queue)))
+            (stream_has_enough_packets(is->m_paudio_stream[is->m_icurrent_index], is->audio_idx[is->m_icurrent_index], &is->audio_pkt_queue) &&
+             stream_has_enough_packets(is->m_pvideo_stream[is->m_icurrent_index], is->video_idx[is->m_icurrent_index], &is->video_pkt_queue)))
         {
             /* wait 10 ms */
             SDL_LockMutex(wait_mutex);
-            SDL_CondWaitTimeout(is->continue_read_thread, wait_mutex, 10);
+            SDL_CondWaitTimeout(is->m_continue_read_thread, wait_mutex, 10);
             SDL_UnlockMutex(wait_mutex);
             continue;
         }
 
         // 4.1 从输入文件中读取一个packet
-        ret = av_read_frame(is->p_fmt_ctx[is->icurrent_index], pkt);
+        ret = av_read_frame(is->m_pfmt_ctx[is->m_icurrent_index], pkt);
         if (ret < 0)
         {
             if (AVERROR_EOF == ret)
             {
                 // 输入文件已读完,则往packet队列中发送NULL packet,以冲洗(flush)解码器,否则解码器中缓存的帧取不出来
-                if (is->video_idx[is->icurrent_index] >= 0){
-                    packet_queue_put_nullpacket(&is->video_pkt_queue, is->video_idx[is->icurrent_index], is->rvc_hostapi);
+                if (is->video_idx[is->m_icurrent_index] >= 0){
+                    packet_queue_put_nullpacket(&is->video_pkt_queue, is->video_idx[is->m_icurrent_index], is->rvc_hostapi);
                 }
-
-                if (is->audio_idx[is->icurrent_index] >= 0){
-                    packet_queue_put_nullpacket(&is->audio_pkt_queue, is->audio_idx[is->icurrent_index], is->rvc_hostapi);
+                if (is->audio_idx[is->m_icurrent_index] >= 0){
+                    packet_queue_put_nullpacket(&is->audio_pkt_queue, is->audio_idx[is->m_icurrent_index], is->rvc_hostapi);
                 }
 
-				if (is->icurrent_index + 1 < is->uFilesCount){
-					is->icurrent_index++;
+				if (is->m_icurrent_index + 1 < is->m_uFilesCount){
+					is->m_icurrent_index++;
 					ret = 0;
-					is->rvc_hostapi->Debug(MEDIA_LOG_DEBUG, "begin %s av_read_frame, nFilecount is %d, current is->index is %d.", is->strPlayLists[is->icurrent_index], is->uFilesCount, is->icurrent_index);
+					is->rvc_hostapi->Debug(MEDIA_LOG_DEBUG, "begin %s av_read_frame, nFilecount is %d, current is->index is %d.", is->m_strPlayLists[is->m_icurrent_index], is->m_uFilesCount, is->m_icurrent_index);
 				}
 				else {
 					is->rvc_hostapi->Debug(MEDIA_LOG_DEBUG, "av_read_frame ret is AVERROR_EOF.");
@@ -157,16 +160,16 @@ static int demux_thread(void *arg)
             }
 
             SDL_LockMutex(wait_mutex);
-            SDL_CondWaitTimeout(is->continue_read_thread, wait_mutex, 10);
+            SDL_CondWaitTimeout(is->m_continue_read_thread, wait_mutex, 10);
             SDL_UnlockMutex(wait_mutex);
             continue;
         }
         
         // 4.3 根据当前packet类型(音频、视频、字幕),将其存入对应的packet队列
-        if (pkt->stream_index == is->audio_idx[is->icurrent_index]){
+        if (pkt->stream_index == is->audio_idx[is->m_icurrent_index]){
             packet_queue_put(&is->audio_pkt_queue, pkt, is->rvc_hostapi);
         }
-        else if (pkt->stream_index == is->video_idx[is->icurrent_index]){
+        else if (pkt->stream_index == is->video_idx[is->m_icurrent_index]){
             packet_queue_put(&is->video_pkt_queue, pkt, is->rvc_hostapi);
         }
         else{
@@ -175,7 +178,7 @@ static int demux_thread(void *arg)
     }
 
     SDL_DestroyMutex(wait_mutex);
-	is->rvc_hostapi->Debug(MEDIA_LOG_DEBUG, "%s exit, thread id is %u, buser_stop flag is %s.",SDL_GetThreadName(is->read_tid), SDL_ThreadID(), is->buser_stop ? "true" : "false");
+	is->rvc_hostapi->Debug(MEDIA_LOG_DEBUG, "%s exit, thread id is %u, buser_stop flag is %s.",SDL_GetThreadName(is->m_read_tid), SDL_ThreadID(), is->buser_stop ? "true" : "false");
 
     return 0;
 }
@@ -188,13 +191,13 @@ int open_demux(player_stat_t *is)
         return -1;
     }
 
-    is->read_tid = SDL_CreateThread(demux_thread, "demux_thread", is);
-    if (is->read_tid == NULL){
+    is->m_read_tid = SDL_CreateThread(demux_thread, "demux_thread", is);
+    if (is->m_read_tid == NULL){
 		is->rvc_hostapi->Debug(MEDIA_LOG_ERROR, "SDL_CreateThread() failed: %s.", SDL_GetError());
         return -1;
     }
 	else {
-		is->rvc_hostapi->Debug(MEDIA_LOG_DEBUG, "create %s success, and thread id is %u.", SDL_GetThreadName(is->read_tid), SDL_GetThreadID(is->read_tid));
+		is->rvc_hostapi->Debug(MEDIA_LOG_DEBUG, "create %s success, and thread id is %u.", SDL_GetThreadName(is->m_read_tid), SDL_GetThreadID(is->m_read_tid));
 	}
 
     return 0;

+ 0 - 0
Other/unix/libmediaplayer/demux.h → Other/libmediaplayer/demux.h


+ 0 - 0
Other/unix/libmediaplayer/frame.cpp → Other/libmediaplayer/frame.cpp


+ 0 - 0
Other/unix/libmediaplayer/frame.h → Other/libmediaplayer/frame.h


+ 3 - 3
Other/win/libmediaplayer/idatastruct.h → Other/libmediaplayer/idatastruct.h

@@ -13,7 +13,7 @@
 
 
 #ifndef TIME_LEN
-#define TIME_LEN      9
+#define TIME_LEN      16
 #endif // !TIME_LEN
 
 #ifndef MAX_FILECOUNT
@@ -77,7 +77,7 @@ struct RVC_NO_VTABLE CMediaHostApi
 	virtual int LoadPlayConfig(CMediaPlayConfig& config, int CfgInx = 0) = 0;
 	virtual void Debug(media_loglevel log_level, const char* fmt, ...) = 0;
 	virtual void MediaPlayFinished(int iMediaType) = 0;
-	virtual int GetMediaPlayerIcoPath(char* strPath, size_t uLen) = 0;
-	virtual int GetAudioOutDevName(char* strDev, size_t uLen) = 0;
+	virtual int GetMediaPlayerIcoPath(char* strPath, int iLen) = 0;
+	virtual int GetAudioOutDevName(char* strDev, int iLen) = 0;
 	virtual int PlayingAudioDataCallback(audio_param_t *param, const void* input, unsigned long uaudiolen) = 0;
 };

+ 53 - 191
Other/win/libmediaplayer/libmediaplayer.cpp → Other/libmediaplayer/libmediaplayer.cpp

@@ -1,8 +1,21 @@
-#include "libmediaplayer.h"
+#include "libmediaplayer.h"
 #include "player.h"
+#ifdef _WIN32
 #include <stdlib.h>
 #include <string.h>
 #include <io.h>
+#else
+#include <unistd.h>
+#endif
+
+
+#ifndef RVC_DEFAULT_VIDEO_WIDTH
+#define RVC_DEFAULT_VIDEO_WIDTH 1920
+#endif // !RVC_DEFAULT_VIDEO_WIDTH
+
+#ifndef RVC_DEFAULT_VIDEO_HEIGHT
+#define RVC_DEFAULT_VIDEO_HEIGHT 1080
+#endif // !RVC_DEFAULT_VIDEO_HEIGHT
 
 class libmediaplayer_impl
 {
@@ -20,15 +33,11 @@ public:
 
 	bool isStop();
 	void PlayMediaFinished();
-	int StartPlayVideo(const char* pVideoDir, const char* pNamePrefix = NULL, int nVideoCount = 1);
 	int GetLocalAudioPlayingParams(rvc_media_player_param_t* pParam, const char* pAudioNames);
 	int StartPlayLocalAudio(const char* pAudioNames);
-	int GetLocalVideoPlayingParams(rvc_media_player_param_t* pParam);
-	int StartPlayLocalVideo(int nCfgInx, int nWndX, int nWndY, int nWndWidth, int nWndHeight);
 	int StartPlayMedia(CMediaPlayConfig& config);
 	bool StopPlay();
 	void SetVolume(int nVolume);
-	void StartPlaySalesRecordVideo(int nWndX, int nWndY, int nWndWidth, int nWndHeight, const char* pVideoDir, const char* pNamePrefix = NULL, int nVideoCount = 1);
 	void StartPlayVideoNotice(int nWndX, int nWndY, int nWndWidth, int nWndHeight, const char* pFileName);
 	bool checkIsPlay();
 	bool checkIsStop();
@@ -42,9 +51,15 @@ bool IsFileExist(const char* pFilePath)
 {
 	bool bRet = false;
 	if (NULL != pFilePath) {
+#ifdef _WIN32
+		if (0 == _access(pFilePath, 0)) {
+			bRet = true;
+	}
+#else
 		if (0 == access(pFilePath, 0)) {
 			bRet = true;
 		}
+#endif // _WIN32
 	}
 	return bRet;
 }
@@ -53,15 +68,23 @@ bool IsFileExist(const char* pFilePath)
 void CStringSplit(char* str, char** result, const char* del)
 {
 	char* ptr = NULL;
+#ifdef _WIN32
 	char* p = strtok_s(str, del, &ptr);
 	while (p != NULL)
 	{
 		*result++ = p;
 		p = strtok_s(NULL, del, &ptr);
 	}
+#else
+	char* p = strtok_r(str, del, &ptr);
+	while (p != NULL)
+	{
+		*result++ = p;
+		p = strtok_r(NULL, del, &ptr);
+	}
+#endif
 }
 
-
 static void __cb_play_finished(void* user_data)
 {
 	libmediaplayer_impl* pthis = static_cast<libmediaplayer_impl*>(user_data);
@@ -96,7 +119,6 @@ libmediaplayer_impl::libmediaplayer_impl(CMediaHostApi* pHostApi)
 	m_bisplaying = false;
 }
 
-
 libmediaplayer_impl::~libmediaplayer_impl()
 {
 	m_pHostApi = NULL;
@@ -105,13 +127,11 @@ libmediaplayer_impl::~libmediaplayer_impl()
 	m_bisplaying = false;
 }
 
-
 bool libmediaplayer_impl::isStop() 
 {
 	return !m_bisplaying; 
 }
 
-
 void libmediaplayer_impl::PlayMediaFinished()
 {
 	m_pHostApi->Debug(MEDIA_LOG_DEBUG, "PlayMediaFinished!");
@@ -156,45 +176,6 @@ bool libmediaplayer_impl::IsFileValid(const char* pVideoName)
 }
 
 
-int libmediaplayer_impl::StartPlayVideo(const char* pVideoDir, const char* pNamePrefix, int nVideoCount)
-{
-	int iRet = -1;
-	if (NULL == pVideoDir || NULL == pNamePrefix) {
-		return iRet;
-	}
-
-	play_media_callback_t cb = {0};
-	cb.cb_play_media_finished = &__cb_play_finished;
-	cb.user_data = this;
-
-	m_pHostApi->Debug(MEDIA_LOG_DEBUG, "audio root path is %s.", pVideoDir);
-	char strVideoName[MAX_PATH] = { 0 };
-	snprintf(strVideoName, MAX_PATH, "%s/%s", pVideoDir, pNamePrefix);
-	m_pHostApi->Debug(MEDIA_LOG_DEBUG, "video full path is %s.", strVideoName);
-	if (!IsFileExist(strVideoName)) {
-		return iRet;
-	}
-
-	rvc_media_player_param_t t_param = { 0 };
-	t_param.p_input_file = strVideoName;
-	t_param.cb = &cb;
-	t_param.eType = eVideo_Type;
-	t_param.eWindType = eVideoSize_Type;
-	t_param.idisplaycx = SDL_WINDOWPOS_UNDEFINED;
-	t_param.idisplaycy = SDL_WINDOWPOS_UNDEFINED;
-
-	memcpy(t_param.strPlayLists[0], strVideoName, strlen(strVideoName));
-	t_param.uFilesCount = 1;
-
-	if (0 == m_Player->InitParam(&t_param)) {
-		m_bisplaying = true;
-		iRet = m_Player->StartMediaPlay();
-	}
-
-	return iRet;
-}
-
-
 int libmediaplayer_impl::GetLocalAudioPlayingParams(rvc_media_player_param_t* pParam, const char* pAudioNames)
 {
 	int iRet = -1;
@@ -203,7 +184,7 @@ int libmediaplayer_impl::GetLocalAudioPlayingParams(rvc_media_player_param_t* pP
 	}
 
 	pParam->eType = eAudio_Type;
-	pParam->eWindType = eVideoSize_Type;
+	pParam->m_eWindType = eVideoSize_Type;
 
 	size_t uLen = strlen(pAudioNames);
 	char* Tmp = new char[uLen + 1];
@@ -220,14 +201,14 @@ int libmediaplayer_impl::GetLocalAudioPlayingParams(rvc_media_player_param_t* pP
 	}
 	m_stPlayConfig.bPrimMonitor = true;
 	m_stPlayConfig.nFileCnt = FileCount;
-	m_pHostApi->Debug(MEDIA_LOG_DEBUG, "wmp pAudioNames = %s!", pAudioNames);
-	m_pHostApi->Debug(MEDIA_LOG_DEBUG, "wmp config.nFileCnt = %d!", FileCount);
+	m_pHostApi->Debug(MEDIA_LOG_DEBUG, "AudioNames = %s!", pAudioNames);
+	m_pHostApi->Debug(MEDIA_LOG_DEBUG, "Audio config.nFileCnt = %d!", FileCount);
 	size_t uValidCount = 0;
 	for (int i = 0; i < FileCount && i < MAX_FILECOUNT; i++) {
 		char strFileName[MAX_PATH] = { 0 };
 		snprintf(strFileName, MAX_PATH, "%s%s", m_stPlayConfig.strRootPath, Result[i]);
 		if (IsFileExist(strFileName)) {
-			memcpy(pParam->strPlayLists[i], strFileName, strlen(strFileName));
+			memcpy(pParam->m_strPlayLists[i], strFileName, strlen(strFileName));
 			uValidCount++;
 		}
 		else {
@@ -238,8 +219,8 @@ int libmediaplayer_impl::GetLocalAudioPlayingParams(rvc_media_player_param_t* pP
 	delete[] Tmp;
 	Tmp = NULL;
 
-	pParam->uFilesCount = uValidCount;
-	m_pHostApi->Debug(MEDIA_LOG_DEBUG, "pParam uFilesCount = %d", pParam->uFilesCount);
+	pParam->m_uFilesCount = uValidCount;
+	m_pHostApi->Debug(MEDIA_LOG_DEBUG, "pParam m_uFilesCount = %d", pParam->m_uFilesCount);
 	if (uValidCount > 0) {
 		iRet = 0;
 	}
@@ -288,134 +269,35 @@ int libmediaplayer_impl::StartPlayLocalAudio(const char* pAudioNames)
 }
 
 
-int libmediaplayer_impl::GetLocalVideoPlayingParams(rvc_media_player_param_t* pParam)
-{
-	int iRet = -1;
-	if (NULL == pParam) {
-		return iRet;
-	}
-
-	pParam->eType = eVideo_Type;
-	pParam->eWindType = eFullScreen_Type;
-	size_t uValidCount = 0;
-	for (int i = 0; i < m_stPlayConfig.nFileCnt && i < MAX_FILECOUNT; i++) {
-		char strFileName[MAX_PATH] = { 0 };
-		snprintf(strFileName, MAX_PATH, "%s%s", m_stPlayConfig.strRootPath, m_stPlayConfig.strFileNames[i]);
-		if (IsFileExist(strFileName)) {
-			memcpy(pParam->strPlayLists[i], strFileName, strlen(strFileName));
-			uValidCount++;
-		}
-		else {
-			m_pHostApi->Debug(MEDIA_LOG_DEBUG, "File %s is not exist.", strFileName);
-			continue;
-		}
-	}
-	pParam->uFilesCount = uValidCount;
-	m_pHostApi->Debug(MEDIA_LOG_DEBUG, "pParam uFilesCount = %d", pParam->uFilesCount);
-	if (uValidCount > 0) {
-		iRet = 0;
-	}
-
-	return iRet;
-}
-
-
-int libmediaplayer_impl::StartPlayLocalVideo(int nCfgInx, int nWndX, int nWndY, int nWndWidth, int nWndHeight)
-{
-	int iRet = -1;
-	m_stPlayConfig.eMode = MEDIA_LOCALVIDEO;
-	m_pHostApi->Debug(MEDIA_LOG_DEBUG, "nCfgInx=%d, nWndX=%d, nWndY=%d, nWndWidth=%d, nWndHeight=%d!", nCfgInx, nWndX, nWndY, nWndWidth, nWndHeight);
-	iRet = m_pHostApi->LoadPlayConfig(m_stPlayConfig, nCfgInx);
-	m_stPlayConfig.eMode = MEDIA_LOCALVIDEO;
-	m_stPlayConfig.nWndX = nWndX;
-	m_stPlayConfig.nWndY = nWndY;
-	m_stPlayConfig.nWndWidth = nWndWidth;
-	m_stPlayConfig.nWndHeight = nWndHeight;
-	if (0 != iRet) {
-		m_pHostApi->Debug(MEDIA_LOG_DEBUG, "Load WmpConfiguration failed while play local video!");
-		return iRet;
-	}
-	else {
-		m_pHostApi->Debug(MEDIA_LOG_DEBUG, "Load WmpConfiguration succeeded while play local video!");
-		m_pHostApi->Debug(MEDIA_LOG_DEBUG, "m_stPlayConfig.strRootPath: %s,m_stPlayConfig.nFileCnt:%d", m_stPlayConfig.strRootPath, m_stPlayConfig.nFileCnt);
-	}
-
-	struct tm* ptm = NULL;
-	time_t t = time(NULL);
-	ptm = localtime(&t);
-	char strNow[TIME_LEN] = { 0 };
-	sprintf(strNow, "%02d:%02d:%02d", ptm->tm_hour, ptm->tm_min, ptm->tm_sec);
-	if (strcmp(strNow, m_stPlayConfig.strVideoRunTime_S) < 0 || strcmp(strNow, m_stPlayConfig.strVideoRunTime_E) >= 0)
-	{
-		//m_pHostApi->Debug("Now is %s, video play start time is %s, video play stop time is %s, play video rejected!", strNow, m_stPlayConfig.strVideoRunTime_S, m_stPlayConfig.strVideoRunTime_E);
-		iRet = 0;
-		return iRet;
-	}
-
-	rvc_media_player_param_t t_param = { 0 };
-	if (0 != GetLocalVideoPlayingParams(&t_param)) {
-		return iRet;
-	}
-
-	t_param.idisplaycx = SDL_WINDOWPOS_UNDEFINED;
-	t_param.idisplaycy = SDL_WINDOWPOS_UNDEFINED;
-	t_param.bvicemonitor = true;
-
-	play_media_callback_t cb = { 0 };
-	cb.cb_play_media_finished = &__cb_play_finished;
-	cb.user_data = this;
-	t_param.cb = &cb;
-
-	if (0 == m_Player->InitParam(&t_param)) {
-		m_bisplaying = true;
-		iRet = m_Player->StartMediaPlay();
-	}
-	else {
-		m_pHostApi->Debug(MEDIA_LOG_DEBUG, "player init failed!");
-	}
-
-	return iRet;
-}
-
 
 int libmediaplayer_impl::StartPlayMedia(CMediaPlayConfig& config)
 {
 	int iRet = -1;
 	memcpy(&m_stPlayConfig, &config, sizeof(CMediaPlayConfig));
 
-	struct tm* ptm = NULL;
-	time_t t = time(NULL);
-	ptm = localtime(&t);
-	char strNow[TIME_LEN] = { 0 };
-	snprintf(strNow, TIME_LEN, "%02d:%02d:%02d", ptm->tm_hour, ptm->tm_min, ptm->tm_sec);
-	if (strcmp(strNow, m_stPlayConfig.strVideoRunTime_S) < 0 || strcmp(strNow, m_stPlayConfig.strVideoRunTime_E) >= 0)
-	{
-		m_pHostApi->Debug(MEDIA_LOG_DEBUG, "Now is %s, video play start time is %s, video play stop time is %s, play video rejected!", strNow, m_stPlayConfig.strVideoRunTime_S, m_stPlayConfig.strVideoRunTime_E);
-		iRet = -2;
-		return iRet;
-	}
-
 	rvc_media_player_param_t t_param = { 0 };
-	//if (0 != GetLocalVideoPlayingParams(&t_param)) {
-	//	return iRet;
-	//}
-	t_param.eType = eVideo_Type;
-	t_param.eWindType = eFullScreen_Type;
-	t_param.bvicemonitor = true;
 
-	char strFileName[MAX_PATH] = { 0 };
-	snprintf(strFileName, MAX_PATH, "%s%s", m_stPlayConfig.strRootPath, m_stPlayConfig.strFileNames[0]);
+	t_param.eType = eVideo_Type;
+	t_param.m_eWindType = eFullScreen_Type;
+	t_param.bvicemonitor = !m_stPlayConfig.bPrimMonitor;
+	t_param.idisplaycx = m_stPlayConfig.nWndX;
+	t_param.idisplaycy = m_stPlayConfig.nWndY;
+	t_param.idisplaywidth = m_stPlayConfig.nWndWidth > 0 ? m_stPlayConfig.nWndWidth : RVC_DEFAULT_VIDEO_WIDTH;
+	t_param.idisplayheight = m_stPlayConfig.nWndHeight > 0 ? m_stPlayConfig.nWndHeight : RVC_DEFAULT_VIDEO_HEIGHT;
+
+	char strFileName[MAX_PATH*2] = { 0 };
+	snprintf(strFileName, MAX_PATH*2, "%s%s", m_stPlayConfig.strRootPath, m_stPlayConfig.strFileNames[0]);
 	if (IsFileExist(strFileName)) {
-		memcpy(t_param.strPlayLists[0], strFileName, strlen(strFileName));
-		t_param.uFilesCount = 1;
+		memcpy(t_param.m_strPlayLists[0], strFileName, strlen(strFileName));
+		t_param.m_uFilesCount = 1;
 	}
 	else {
 		m_pHostApi->Debug(MEDIA_LOG_DEBUG, "File %s is not exist.", strFileName);
-		t_param.uFilesCount = 0;
+		t_param.m_uFilesCount = 0;
 		return iRet;
 	}
 
-	m_pHostApi->Debug(MEDIA_LOG_DEBUG, "pParam uFilesCount = %d", t_param.uFilesCount);
+	m_pHostApi->Debug(MEDIA_LOG_DEBUG, "pParam m_uFilesCount = %d", t_param.m_uFilesCount);
 
 	play_media_callback_t cb = { 0 };
 	cb.cb_play_media_finished = &__cb_play_finished;
@@ -451,28 +333,23 @@ void libmediaplayer_impl::SetVolume(int nVolume)
 	}
 }
 
-void libmediaplayer_impl::StartPlaySalesRecordVideo(int nWndX, int nWndY, int nWndWidth, int nWndHeight, const char* pVideoDir, const char* pNamePrefix, int nVideoCount)
-{
-
-}
 
 void libmediaplayer_impl::StartPlayVideoNotice(int nWndX, int nWndY, int nWndWidth, int nWndHeight, const char* pFileName)
 {
-	int iRet = -1;
 	if (NULL == pFileName) {
 		return;
 	}
 
 	rvc_media_player_param_t t_param = { 0 };
-	t_param.uFilesCount = 1;
+	t_param.m_uFilesCount = 1;
 	t_param.eType = eVideo_Type;
-	t_param.eWindType = eSpecified_Type;
+	t_param.m_eWindType = eSpecified_Type;
 	t_param.idisplaycx = nWndX;
 	t_param.idisplaycy = nWndY;
 	t_param.idisplaywidth = nWndWidth;
 	t_param.idisplayheight = nWndHeight;
 	t_param.bvicemonitor = false;
-	memcpy(&t_param.strPlayLists[0], pFileName, strlen(pFileName));
+	memcpy(&t_param.m_strPlayLists[0], pFileName, strlen(pFileName));
 
 	play_media_callback_t cb = { 0 };
 	cb.cb_play_media_finished = &__cb_play_finished;
@@ -481,7 +358,7 @@ void libmediaplayer_impl::StartPlayVideoNotice(int nWndX, int nWndY, int nWndWid
 
 	if (0 == m_Player->InitParam(&t_param)) {
 		m_bisplaying = true;
-		iRet = m_Player->StartMediaPlay();
+		m_Player->StartMediaPlay();
 	}
 	else {
 		m_pHostApi->Debug(MEDIA_LOG_DEBUG, "player init failed!");
@@ -518,10 +395,6 @@ Clibmediaplayer::~Clibmediaplayer()
 	m_pImpl = NULL;
 }
 
-int Clibmediaplayer::PlayVideo(const char* pVideoDir, const char* pNamePrefix, int nVideoCount)
-{
-	return m_pImpl->StartPlayVideo(pVideoDir, pNamePrefix, nVideoCount);
-}
 
 int Clibmediaplayer::PlayLocalAudio(const char* pAudioNames)
 {
@@ -529,11 +402,6 @@ int Clibmediaplayer::PlayLocalAudio(const char* pAudioNames)
 	return m_pImpl->StartPlayLocalAudio(pAudioNames);
 }
 
-int Clibmediaplayer::PlayLocalVideo(int nCfgInx, int nWndX, int nWndY, int nWndWidth, int nWndHeight)
-{
-	return m_pImpl->StartPlayLocalVideo(nCfgInx, nWndX, nWndY, nWndWidth, nWndHeight);
-}
-
 bool Clibmediaplayer::checkIsPlay()
 {
 	return m_pImpl->checkIsPlay();
@@ -559,17 +427,11 @@ void Clibmediaplayer::SetVolume(int nVolume)
 	m_pImpl->SetVolume(nVolume);
 }
 
-void Clibmediaplayer::PlaySalesRecordVideo(int nWndX, int nWndY, int nWndWidth, int nWndHeight, const char* pVideoDir, const char* pNamePrefix, int nVideoCount)
-{
-	m_pImpl->StartPlaySalesRecordVideo(nWndX, nWndY, nWndWidth, nWndHeight, pVideoDir, pNamePrefix, nVideoCount);
-}
-
 void Clibmediaplayer::PlayVideoNotice(int nWndX, int nWndY, int nWndWidth, int nWndHeight, const char* pFileName)
 {
 	m_pImpl->StartPlayVideoNotice(nWndX, nWndY, nWndWidth, nWndHeight, pFileName);
 }
 
-
 bool Clibmediaplayer::IsFileValid(const char* pVideoName)
 {
 	return m_pImpl->IsFileValid(pVideoName);

+ 0 - 6
Other/win/libmediaplayer/libmediaplayer.h → Other/libmediaplayer/libmediaplayer.h

@@ -24,12 +24,8 @@ public:
 
 	~Clibmediaplayer();
 
-	int PlayVideo(const char* pVideoDir, const char* pNamePrefix = NULL, int nVideoCount = 1);
-
 	int PlayLocalAudio(const char* pAudioNames);
 
-	int PlayLocalVideo(int nCfgInx, int nWndX, int nWndY, int nWndWidth, int nWndHeight);
-
 	void Close();
 
 	bool checkIsPlay();
@@ -40,8 +36,6 @@ public:
 
 	void SetVolume(int nVolume);
 
-	void PlaySalesRecordVideo(int nWndX, int nWndY, int nWndWidth, int nWndHeight, const char* pVideoDir, const char* pNamePrefix = NULL, int nVideoCount = 1);
-
 	void PlayVideoNotice(int nWndX, int nWndY, int nWndWidth, int nWndHeight, const char* pVideoName);
 
 	bool IsFileValid(const char* pVideoName);

+ 5 - 5
Other/unix/libmediaplayer/packet.cpp → Other/libmediaplayer/packet.cpp

@@ -41,12 +41,11 @@ int packet_queue_put(packet_queue_t *q, AVPacket *pkt, CMediaHostApi* hostapi)
 
     SDL_LockMutex(q->mutex);
 
-    if (!q->last_pkt)   // 队列为空
-    {
+	// 队列为空
+    if (!q->last_pkt){
         q->first_pkt = pkt_list;
     }
-    else
-    {
+    else{
         q->last_pkt->next = pkt_list;
     }
     q->last_pkt = pkt_list;
@@ -61,9 +60,10 @@ int packet_queue_put(packet_queue_t *q, AVPacket *pkt, CMediaHostApi* hostapi)
 }
 
 // 读队列头部。
-int packet_queue_get(packet_queue_t *q, AVPacket *pkt, int block)
+int packet_queue_get(packet_queue_t *q, AVPacket *pkt, int block, CMediaHostApi* hostapi)
 {
     AVPacketList *p_pkt_node = NULL;
+
     int ret = -1;
 
     SDL_LockMutex(q->mutex);

+ 0 - 0
Other/win/libmediaplayer/packet.h → Other/libmediaplayer/packet.h


+ 94 - 80
Other/unix/libmediaplayer/player.cpp → Other/libmediaplayer/player.cpp

@@ -75,20 +75,20 @@ static void sync_play_clock_to_slave(play_clock_t *c, play_clock_t *slave)
 /* pause or resume the video */
 static void stream_toggle_pause(player_stat_t *is)
 {
-    if (is->paused)
+    if (is->m_ipaused)
     {
         // 这里表示当前是暂停状态,将切换到继续播放状态。在继续播放之前,先将暂停期间流逝的时间加到frame_timer中
         is->frame_timer += av_gettime_relative() / 1000000.0 - is->video_clk.last_updated;
         set_clock(&is->video_clk, get_clock(&is->video_clk), is->video_clk.serial);
     }
-    is->paused = is->audio_clk.paused = is->video_clk.paused = !is->paused;
+    is->m_ipaused = is->audio_clk.paused = is->video_clk.paused = !is->m_ipaused;
 }
 
 
 static void toggle_pause(player_stat_t *is)
 {
     stream_toggle_pause(is);
-    is->step = 0;
+    is->m_istep = 0;
 }
 
 static void toggle_full_screen(player_stat_t* is)
@@ -184,7 +184,7 @@ bool CMediaPlayer::SetFinishedFlag()
 	if (NULL != m_player_stat){
 		//m_player_stat->baudio_finished = true;
 		if (NULL != m_hostapi) {
-			m_hostapi->Debug(MEDIA_LOG_INFO, "%s:%d set baudio_finished to true.", __FUNCTION__, __LINE__);
+			m_hostapi->Debug(MEDIA_LOG_DEBUG, "%s:%d set baudio_finished to true.", __FUNCTION__, __LINE__);
 		}
 	}
 	else {
@@ -203,7 +203,7 @@ uint8_t CMediaPlayer::GetVolume()
 
 eMediaType_t CMediaPlayer::GetPlayingMediaType()
 {
-	return m_player_stat->eMType;
+	return m_player_stat->m_eMType;
 }
 
 int CMediaPlayer::Initialize_Player_Stat(rvc_media_player_param_t* pMedia_Player)
@@ -226,9 +226,9 @@ int CMediaPlayer::Initialize_Player_Stat(rvc_media_player_param_t* pMedia_Player
 
 	m_player_stat->buser_stop = false;
 	m_player_stat->rvc_hostapi = m_hostapi;
-	m_player_stat->prvc_cb = pMedia_Player->cb;
-	m_player_stat->eMType = pMedia_Player->eType;
-	m_player_stat->eWindType = pMedia_Player->eWindType;
+	m_player_stat->m_prvc_cb = pMedia_Player->cb;
+	m_player_stat->m_eMType = pMedia_Player->eType;
+	m_player_stat->m_eWindType = pMedia_Player->m_eWindType;
 	m_player_stat->bvice_monitor = pMedia_Player->bvicemonitor;
 	m_player_stat->iDisplayCx = pMedia_Player->idisplaycx;
 	m_player_stat->iDisplayCy = pMedia_Player->idisplaycy;
@@ -238,21 +238,21 @@ int CMediaPlayer::Initialize_Player_Stat(rvc_media_player_param_t* pMedia_Player
 	m_player_stat->on_audio_play_finished = &audio_play_finished_callback;
 	m_player_stat->user_data = this;
 	if (NULL != m_piconpath){
-		m_player_stat->piconpath = av_strdup(m_piconpath);
+		m_player_stat->m_piconpath = av_strdup(m_piconpath);
 	}
 
 	if (NULL != m_paudiodev){
-		m_player_stat->paudiodev = av_strdup(m_paudiodev);
+		m_player_stat->m_paudiodev = av_strdup(m_paudiodev);
 	}
 	m_player_stat->uVolume = m_uvolume;
-	m_player_stat->uFilesCount = pMedia_Player->uFilesCount;
-	m_player_stat->icurrent_index = 0;
-	m_player_stat->iaudio_dec_index = 0;
-	for (size_t i = 0; i < pMedia_Player->uFilesCount; i++){
-		memcpy(m_player_stat->strPlayLists[i], pMedia_Player->strPlayLists[i], strlen(pMedia_Player->strPlayLists[i]));
+	m_player_stat->m_uFilesCount = pMedia_Player->m_uFilesCount;
+	m_player_stat->m_icurrent_index = 0;
+	m_player_stat->m_iaudio_dec_index = 0;
+	for (size_t i = 0; i < pMedia_Player->m_uFilesCount; i++){
+		memcpy(m_player_stat->m_strPlayLists[i], pMedia_Player->m_strPlayLists[i], strlen(pMedia_Player->m_strPlayLists[i]));
 	}
 
-	if (0 == pMedia_Player->uFilesCount || NULL == m_player_stat->rvc_hostapi || NULL == m_player_stat->prvc_cb || NULL == m_player_stat->piconpath) {
+	if (0 == pMedia_Player->m_uFilesCount || NULL == m_player_stat->rvc_hostapi || NULL == m_player_stat->m_prvc_cb || NULL == m_player_stat->m_piconpath) {
 		UnInitialize_Player_Stat();
 		return iRet;
 	}
@@ -271,44 +271,47 @@ int CMediaPlayer::UnInitialize_Player_Stat()
 		return -1;
 	}
 
-	if (NULL != m_player_stat->read_tid){
-		SDL_WaitThread(m_player_stat->read_tid, NULL);
-		m_player_stat->read_tid = NULL;
+	if (NULL != m_player_stat->m_read_tid){
+		SDL_WaitThread(m_player_stat->m_read_tid, NULL);
+		m_player_stat->m_read_tid = NULL;
 		m_hostapi->Debug(MEDIA_LOG_DEBUG, "demux thread finished.");
 	}
 
-	for (int index = 0; index < m_player_stat->uFilesCount; index++) {
-		if (NULL != m_player_stat->p_fmt_ctx[index]) {
-			avformat_close_input(&m_player_stat->p_fmt_ctx[index]);
-			m_player_stat->p_fmt_ctx[index] = NULL;
+	for (int index = 0; index < m_player_stat->m_uFilesCount; index++) {
+		if (NULL != m_player_stat->m_pfmt_ctx[index]) {
+			avformat_close_input(&m_player_stat->m_pfmt_ctx[index]);
+			avformat_free_context(m_player_stat->m_pfmt_ctx[index]);
+			m_player_stat->m_pfmt_ctx[index] = NULL;
 		}
 
-		if (NULL != m_player_stat->p_acodec_ctx[index]) {
-			avcodec_free_context(&m_player_stat->p_acodec_ctx[index]);
+		if (NULL != m_player_stat->m_pacodec_ctx[index]) {
+			avcodec_close(m_player_stat->m_pacodec_ctx[index]);
+			avcodec_free_context(&m_player_stat->m_pacodec_ctx[index]);
 		}
 
-		if (NULL != m_player_stat->p_vcodec_ctx[index]) {
-			avcodec_free_context(&m_player_stat->p_vcodec_ctx[index]);
+		if (NULL != m_player_stat->m_pvcodec_ctx[index]) {
+			avcodec_close(m_player_stat->m_pvcodec_ctx[index]);
+			avcodec_free_context(&m_player_stat->m_pvcodec_ctx[index]);
 		}
 	}
 	
-	SDL_DestroyCond(m_player_stat->continue_read_thread);
-	SDL_DestroyCond(m_player_stat->audio_play_cond);
-	SDL_DestroyMutex(m_player_stat->audio_play_wait_mutex);
-
-	if (m_player_stat->eMType == eVideo_Type) {
-		for (int index = 0; index < m_player_stat->uFilesCount; index++) {
-			if (NULL != m_player_stat->img_convert_ctx[index]) {
-				sws_freeContext(m_player_stat->img_convert_ctx[index]);
-				m_player_stat->img_convert_ctx[index] = NULL;
+	SDL_DestroyCond(m_player_stat->m_continue_read_thread);
+	SDL_DestroyCond(m_player_stat->m_audio_play_cond);
+	SDL_DestroyMutex(m_player_stat->m_audio_play_wait_mutex);
+
+	if (m_player_stat->m_eMType == eVideo_Type) {
+		for (int index = 0; index < m_player_stat->m_uFilesCount; index++) {
+			if (NULL != m_player_stat->m_pimg_convert_ctx[index]) {
+				sws_freeContext(m_player_stat->m_pimg_convert_ctx[index]);
+				m_player_stat->m_pimg_convert_ctx[index] = NULL;
 			}
-			if (NULL != m_player_stat->p_frm_yuv[index]) {
-				av_frame_free(&m_player_stat->p_frm_yuv[index]);
-				av_frame_unref(m_player_stat->p_frm_yuv[index]);
+			if (NULL != m_player_stat->m_pfrm_yuv[index]) {
+				av_frame_free(&m_player_stat->m_pfrm_yuv[index]);
+				av_frame_unref(m_player_stat->m_pfrm_yuv[index]);
 			}
-			if (NULL != m_player_stat->p_video_buffer[index]) {
-				av_free(m_player_stat->p_video_buffer[index]);
-				m_player_stat->p_video_buffer[index] = NULL;
+			if (NULL != m_player_stat->m_pvideo_buffer[index]) {
+				av_free(m_player_stat->m_pvideo_buffer[index]);
+				m_player_stat->m_pvideo_buffer[index] = NULL;
 			}
 		}
 	}
@@ -322,26 +325,31 @@ int CMediaPlayer::UnInitialize_Player_Stat()
 
 	m_hostapi->Debug(MEDIA_LOG_DEBUG, "av_free player_stat_t.");
 
-	swr_free(&m_player_stat->audio_swr_ctx);
+	swr_free(&m_player_stat->m_paudio_swr_ctx);
 
-	if (NULL != m_player_stat->audio_frm_rwr) {
-		av_free(m_player_stat->audio_frm_rwr);
-		m_player_stat->audio_frm_rwr = NULL;
+	//if (NULL != m_player_stat->m_paudio_frm) {
+	//	av_free(m_player_stat->m_paudio_frm);
+	//	m_player_stat->m_paudio_frm = NULL;
+	//}
+
+	if (NULL != m_player_stat->m_paudio_frm_rwr) {
+		av_free(m_player_stat->m_paudio_frm_rwr);
+		m_player_stat->m_paudio_frm_rwr = NULL;
 	}
 
-	if (m_player_stat->piconpath){
-		av_free(m_player_stat->piconpath);
-		m_player_stat->piconpath = NULL;
+	if (m_player_stat->m_piconpath){
+		av_free(m_player_stat->m_piconpath);
+		m_player_stat->m_piconpath = NULL;
 	}
 
-	if (m_player_stat->paudiodev) {
-		av_free(m_player_stat->paudiodev);
-		m_player_stat->paudiodev = NULL;
+	if (m_player_stat->m_paudiodev) {
+		av_free(m_player_stat->m_paudiodev);
+		m_player_stat->m_paudiodev = NULL;
 	}
 
-	if (m_player_stat->straudiodev) {
-		av_free(m_player_stat->straudiodev);
-		m_player_stat->straudiodev = NULL;
+	if (m_player_stat->m_straudiodev) {
+		av_free(m_player_stat->m_straudiodev);
+		m_player_stat->m_straudiodev = NULL;
 	}
 
 	av_free(m_player_stat);
@@ -412,13 +420,13 @@ int CMediaPlayer::InitParam(rvc_media_player_param_t* pMedia_Player)
 	packet_queue_put(&m_player_stat->video_pkt_queue, &flush_pkt, m_hostapi);
 	packet_queue_put(&m_player_stat->audio_pkt_queue, &flush_pkt, m_hostapi);
 
-	if (!(m_player_stat->continue_read_thread = SDL_CreateCond()) || !(m_player_stat->audio_play_cond = SDL_CreateCond())){
+	if (!(m_player_stat->m_continue_read_thread = SDL_CreateCond()) || !(m_player_stat->m_audio_play_cond = SDL_CreateCond())){
 		m_hostapi->Debug(MEDIA_LOG_DEBUG, "SDL_CreateCond(): %s.", SDL_GetError());
 		UnInitialize_Player_Stat();
 		return iRet;
 	}
 
-	m_player_stat->audio_play_wait_mutex = SDL_CreateMutex();
+	m_player_stat->m_audio_play_wait_mutex = SDL_CreateMutex();
 
 	init_clock(&m_player_stat->video_clk, &m_player_stat->video_pkt_queue.serial);
 	init_clock(&m_player_stat->audio_clk, &m_player_stat->audio_pkt_queue.serial);
@@ -474,7 +482,7 @@ int CMediaPlayer::StartMediaPlay()
 	m_hostapi->Debug(MEDIA_LOG_DEBUG, "set playing flag to true.");
 	m_bplaying = true;
 
-	if (eVideo_Type == m_player_stat->eMType) {
+	if (eVideo_Type == m_player_stat->m_eMType) {
 		open_video(m_player_stat);
 	}
 
@@ -482,28 +490,25 @@ int CMediaPlayer::StartMediaPlay()
 
 	m_hostapi->Debug(MEDIA_LOG_DEBUG, "after open_audio function.");
 
-	//packet_queue_abort(&m_player_stat->video_pkt_queue, m_hostapi);
-	//packet_queue_abort(&m_player_stat->audio_pkt_queue, m_hostapi);
-
-	//frame_queue_signal(&m_player_stat->video_frm_queue);
-	//frame_queue_signal(&m_player_stat->audio_frm_queue);
-
-	if (NULL != m_player_stat->audio_decode_tid) {
-		SDL_WaitThread(m_player_stat->audio_decode_tid, NULL);
-		m_player_stat->audio_decode_tid = NULL;
+	if (NULL != m_player_stat->m_audio_decode_tid) {
+		m_hostapi->Debug(MEDIA_LOG_DEBUG, "wait audio decode thread.");
+		SDL_WaitThread(m_player_stat->m_audio_decode_tid, NULL);
+		m_player_stat->m_audio_decode_tid = NULL;
 		m_hostapi->Debug(MEDIA_LOG_DEBUG, "audio decode thread finished.");
 	}
 
-	if (m_player_stat->eMType == eVideo_Type) {
-		if (NULL != m_player_stat->video_decode_tid) {
-			SDL_WaitThread(m_player_stat->video_decode_tid, NULL);
-			m_player_stat->video_decode_tid = NULL;
+	if (m_player_stat->m_eMType == eVideo_Type) {
+		if (NULL != m_player_stat->m_video_decode_tid) {
+			m_hostapi->Debug(MEDIA_LOG_DEBUG, "wait video decode thread.");
+			SDL_WaitThread(m_player_stat->m_video_decode_tid, NULL);
+			m_player_stat->m_video_decode_tid = NULL;
 			m_hostapi->Debug(MEDIA_LOG_DEBUG, "video decode thread finished.");
 		}
 
-		if (NULL != m_player_stat->video_playing_tid) {
-			SDL_WaitThread(m_player_stat->video_playing_tid, NULL);
-			m_player_stat->video_playing_tid = NULL;
+		if (NULL != m_player_stat->m_video_playing_tid) {
+			m_hostapi->Debug(MEDIA_LOG_DEBUG, "wait video playing thread.");
+			SDL_WaitThread(m_player_stat->m_video_playing_tid, NULL);
+			m_player_stat->m_video_playing_tid = NULL;
 			m_hostapi->Debug(MEDIA_LOG_DEBUG, "video playing thread finished.");
 		}
 	}
@@ -532,11 +537,20 @@ int CMediaPlayer::StopMediaPlay()
 	frame_queue_signal(&m_player_stat->video_frm_queue);
 	frame_queue_signal(&m_player_stat->audio_frm_queue);
 
-	m_hostapi->Debug(MEDIA_LOG_INFO, "%s:%d set m_player_stat media finished flag to true.", __FUNCTION__, __LINE__);
+	m_hostapi->Debug(MEDIA_LOG_INFO, "set m_player_stat media finished flag to true.");
 	m_player_stat->buser_stop = true;
 
+	//if (m_bplaying) {
+	//	m_hostapi->Debug(MEDIA_LOG_DEBUG, "user stop audio play set SDL_PauseAudioDevice param to 1.");
+	//	if (0 != m_player_stat->m_audio_dev){
+	//		SDL_PauseAudioDevice(m_player_stat->m_audio_dev, 1);
+	//	}
+	//}
+
 	iRet = 0;
 
+	m_hostapi->Debug(MEDIA_LOG_DEBUG, "StopMediaPlay exit.");
+
 	return iRet;
 }
 
@@ -551,7 +565,7 @@ int CMediaPlayer::ExitMediaPlayingThread()
 
 	m_hostapi->Debug(MEDIA_LOG_DEBUG, "enter ExitMediaPlayingThread call.");
 
-	if(eVideo_Type == m_player_stat->eMType){
+	if(eVideo_Type == m_player_stat->m_eMType){
 		if (m_player_stat->sdl_video.texture) {
 			SDL_DestroyTexture(m_player_stat->sdl_video.texture);
 		}
@@ -566,9 +580,9 @@ int CMediaPlayer::ExitMediaPlayingThread()
 		}
 	}
 
-	if (m_player_stat->prvc_cb){
+	if (m_player_stat->m_prvc_cb){
 		m_hostapi->Debug(MEDIA_LOG_DEBUG, "cb_play_media_finished callback.");
-		m_player_stat->prvc_cb->cb_play_media_finished(m_player_stat->prvc_cb->user_data);
+		m_player_stat->m_prvc_cb->cb_play_media_finished(m_player_stat->m_prvc_cb->user_data);
 	}
 
 	UnInitialize_Player_Stat();
@@ -588,9 +602,9 @@ int64_t CMediaPlayer::GetMediaPlayingThreadId()
 	int64_t iRet = 0;
 	if (NULL != m_player_stat)
 	{
-		if (NULL != m_player_stat->read_tid)
+		if (NULL != m_player_stat->m_read_tid)
 		{
-			iRet = SDL_GestureID(m_player_stat->read_tid);
+			iRet = SDL_GestureID(m_player_stat->m_read_tid);
 		}
 	}
 

+ 48 - 45
Other/win/libmediaplayer/player.h → Other/libmediaplayer/player.h

@@ -11,6 +11,7 @@
 #define UINT64_C(c) (c##UL) 
 #endif
 
+
 #ifdef __cplusplus
 extern "C"
 {
@@ -76,10 +77,12 @@ extern "C"
 
 #define FF_QUIT_EVENT    (SDL_USEREVENT + 2)
 
+
 #ifndef RVC_MAX_DISPLAYNUM
 #define RVC_MAX_DISPLAYNUM 5
 #endif
 
+
 #ifndef RVC_DEFAULT_SLEEP_TIME
 #define RVC_DEFAULT_SLEEP_TIME 10*1000
 #endif
@@ -153,30 +156,32 @@ typedef struct play_media_callback_s {
 	void* user_data;
 }play_media_callback_t;
 
+
 typedef enum eMediaType_s {
 	eAudio_Type,
 	eVideo_Type,
 	eImage_Type
 }eMediaType_t;
 
+
 static const char* Media_Type_Table[] = {
 	"Audio",
 	"Video",
 	"Image"
 };
 
-typedef enum eWindType_s {
+typedef enum m_eWindType_s {
 	eVideoSize_Type,
 	eFullScreen_Type,
 	eSpecified_Type
-}eWindType_t;
+}m_eWindType_t;
 
 typedef struct player_stat_s{
-    AVFormatContext *p_fmt_ctx[MAX_FILECOUNT];
-    AVStream *p_audio_stream[MAX_FILECOUNT];
-    AVStream *p_video_stream[MAX_FILECOUNT];
-    AVCodecContext *p_acodec_ctx[MAX_FILECOUNT];
-    AVCodecContext *p_vcodec_ctx[MAX_FILECOUNT];
+    AVFormatContext *m_pfmt_ctx[MAX_FILECOUNT];
+    AVStream *m_paudio_stream[MAX_FILECOUNT];
+    AVStream *m_pvideo_stream[MAX_FILECOUNT];
+    AVCodecContext *m_pacodec_ctx[MAX_FILECOUNT];
+    AVCodecContext *m_pvcodec_ctx[MAX_FILECOUNT];
 
     int audio_idx[MAX_FILECOUNT];
     int video_idx[MAX_FILECOUNT];
@@ -193,52 +198,52 @@ typedef struct player_stat_s{
     frame_queue_t audio_frm_queue;
     frame_queue_t video_frm_queue;
 
-    struct SwsContext *img_convert_ctx[MAX_FILECOUNT];
-    struct SwrContext *audio_swr_ctx;
-    AVFrame *p_frm_yuv[MAX_FILECOUNT];
-	uint8_t *p_video_buffer[MAX_FILECOUNT];
+    struct SwsContext *m_pimg_convert_ctx[MAX_FILECOUNT];
+    struct SwrContext *m_paudio_swr_ctx;
+    AVFrame *m_pfrm_yuv[MAX_FILECOUNT];
+	uint8_t *m_pvideo_buffer[MAX_FILECOUNT];
 
-    audio_param_t audio_param_src;
-    audio_param_t audio_param_tgt;
+    audio_param_t m_audio_param_src;
+    audio_param_t m_audio_param_tgt;
     int audio_hw_buf_size;              // SDL音频缓冲区大小(单位字节)
-    uint8_t *p_audio_frm;               // 指向待播放的一帧音频数据,指向的数据区将被拷入SDL音频缓冲区。若经过重采样则指向audio_frm_rwr,否则指向frame中的音频
-    uint8_t *audio_frm_rwr;             // 音频重采样的输出缓冲区
-    unsigned int audio_frm_size;        // 待播放的一帧音频数据(audio_buf指向)的大小
-    unsigned int audio_frm_rwr_size;    // 申请到的音频缓冲区audio_frm_rwr的实际尺寸
+    uint8_t *m_paudio_frm;              // 指向待播放的一帧音频数据,指向的数据区将被拷入SDL音频缓冲区。若经过重采样则指向audio_frm_rwr,否则指向frame中的音频
+    uint8_t *m_paudio_frm_rwr;          // 音频重采样的输出缓冲区
+    uint32_t audio_frm_size;			// 待播放的一帧音频数据(audio_buf指向)的大小
+	uint32_t audio_frm_rwr_size;		// 申请到的音频缓冲区audio_frm_rwr的实际尺寸
     int audio_cp_index;                 // 当前音频帧中已拷入SDL音频缓冲区的位置索引(指向第一个待拷贝字节)
     int audio_write_buf_size;           // 当前音频帧中尚未拷入SDL音频缓冲区的数据量,audio_frm_size = audio_cp_index + audio_write_buf_size
     double audio_clock;
     int audio_clock_serial;
     
-    int paused;
-    int step;
+    int m_ipaused;
+    int m_istep;
 
 	volatile bool buser_stop;
 
-    SDL_cond *continue_read_thread;
-    SDL_Thread *read_tid;           // demux解复用线程
-	SDL_Thread* audio_decode_tid;	// 音频解码线程
-	volatile bool baudio_decode_finished;
-	SDL_Thread* video_decode_tid;   // 视频解码线程
-	volatile bool bvideo_decode_finished;
-	SDL_Thread* video_playing_tid;  // 视频播放线程
-	SDL_cond* audio_play_cond;
-	SDL_mutex* audio_play_wait_mutex;
+    SDL_cond* m_continue_read_thread;
+    SDL_Thread* m_read_tid;				// demux解复用线程
+	SDL_Thread* m_audio_decode_tid;		// 音频解码线程
+	volatile bool m_baudio_decode_finished;
+	SDL_Thread* m_video_decode_tid;		// 视频解码线程
+	volatile bool m_bvideo_decode_finished;
+	SDL_Thread* m_video_playing_tid;	// 视频播放线程
+	SDL_cond* m_audio_play_cond;
+	SDL_mutex* m_audio_play_wait_mutex;
 	
-	play_media_callback_t* prvc_cb;	// 播放状态回调函数
-	char* piconpath;				// icon图标路径
-	char* paudiodev;				// 音频输出设备名
-	eMediaType_t eMType;			// 媒体类型
-	eWindType_t eWindType;			// 视频框大小类型
-	volatile uint8_t uVolume;		// 音量大小1-128
-	char* straudiodev;				// 获取到的音频设备名
+	play_media_callback_t* m_prvc_cb;		// 播放状态回调函数
+	char* m_piconpath;						// icon图标路径
+	char* m_paudiodev;						// 音频输出设备名
+	eMediaType_t m_eMType;					// 媒体类型
+	m_eWindType_t m_eWindType;				// 视频框大小类型
+	volatile uint8_t uVolume;				// 音量大小1-128
+	char* m_straudiodev;					// 获取到的音频设备名
 	CMediaHostApi* rvc_hostapi;
+	SDL_AudioDeviceID m_audio_dev;
 	
-	char strPlayLists[MAX_FILECOUNT][MAX_PATH];		//播放列表,全路径
-	uint8_t uFilesCount;							//播放文件数
-	volatile int icurrent_index;					//当前播放文件索引
-	volatile int iaudio_dec_index;					//当前音频解码器索引
-	bool bCirclePlay;
+	char m_strPlayLists[MAX_FILECOUNT][MAX_PATH];		// 播放列表,全路径
+	uint8_t m_uFilesCount;								// 播放文件数
+	volatile int m_icurrent_index;						// 当前播放文件索引
+	volatile int m_iaudio_dec_index;					// 当前音频解码器索引
 	bool bvice_monitor;
 	int iDisplayCx;
 	int iDisplayCy;
@@ -253,14 +258,14 @@ typedef struct player_stat_s{
 typedef struct rvc_media_player_param_s{
 	char* p_input_file;
 	eMediaType_t eType;
-	eWindType_t eWindType;
+	m_eWindType_t m_eWindType;
 	int idisplaycx;
 	int idisplaycy;
 	int idisplaywidth;
 	int idisplayheight;
 	bool bvicemonitor;
-	char strPlayLists[MAX_FILECOUNT][MAX_PATH];		//播放列表,全路径
-	uint8_t uFilesCount;								//播放文件数
+	char m_strPlayLists[MAX_FILECOUNT][MAX_PATH];		// 播放列表,全路径
+	uint8_t m_uFilesCount;								// 播放文件数
 	play_media_callback_t* cb;
 }rvc_media_player_param_t;
 
@@ -269,8 +274,6 @@ double get_clock(play_clock_t *c);
 void set_clock_at(play_clock_t *c, double pts, int serial, double time);
 void set_clock(play_clock_t *c, double pts, int serial);
 
-static SDL_AudioDeviceID audio_dev;
-
 class CMediaPlayer
 {
 public:

+ 90 - 82
Other/win/libmediaplayer/video.cpp → Other/libmediaplayer/video.cpp

@@ -3,15 +3,6 @@
 #include "frame.h"
 #include "player.h"
 
-//Refresh Event
-#ifndef REFRESH_EVENT
-#define REFRESH_EVENT  (SDL_USEREVENT + 1)
-#endif
-
-#ifndef RVC_DEFAULT_DELAY_TIME
-#define RVC_DEFAULT_DELAY_TIME 1
-#endif
-
 static int queue_picture(player_stat_t *is, AVFrame *src_frame, double pts, double duration, int64_t pos)
 {
     frame_t *vp = NULL;
@@ -92,9 +83,6 @@ static int video_decode_frame(AVCodecContext *p_codec_ctx, packet_queue_t *p_pkt
         if (packet_queue_get(p_pkt_queue, &pkt, true, hostapi) < 0){
             return -1;
         }
-		else{
-			//hostapi->Debug(MEDIA_LOG_DEBUG, "[%p] packet_queue_get pkt and pkt.dts = %u.", p_pkt_queue, pkt.dts);
-		}
 
         if (pkt.data == NULL){
             // 复位解码器内部状态/刷新内部缓冲区。
@@ -146,9 +134,9 @@ static int video_decode_thread(void *arg)
 
     while (false == is->buser_stop)
     {
-		AVRational tb = is->p_video_stream[is->icurrent_index]->time_base;
-		AVRational frame_rate = av_guess_frame_rate(is->p_fmt_ctx[is->icurrent_index], is->p_video_stream[is->icurrent_index], NULL);
-        got_picture = video_decode_frame(is->p_vcodec_ctx[is->icurrent_index], &is->video_pkt_queue, p_frame, is->rvc_hostapi);
+		AVRational tb = is->m_pvideo_stream[is->m_icurrent_index]->time_base;
+		AVRational frame_rate = av_guess_frame_rate(is->m_pfmt_ctx[is->m_icurrent_index], is->m_pvideo_stream[is->m_icurrent_index], NULL);
+        got_picture = video_decode_frame(is->m_pvcodec_ctx[is->m_icurrent_index], &is->video_pkt_queue, p_frame, is->rvc_hostapi);
         if (got_picture < 0){
 			is->rvc_hostapi->Debug(MEDIA_LOG_DEBUG, "video_decode_frame < 0, goto end and set video_finished flag to true.");
             goto exit;
@@ -173,7 +161,7 @@ static int video_decode_thread(void *arg)
 exit:
     av_frame_free(&p_frame);
 	is->rvc_hostapi->Debug(MEDIA_LOG_DEBUG, "video decode thread exit, thread id is %u, and user_stop flag is %s.", SDL_ThreadID(), is->buser_stop ? "true" : "false");
-	is->bvideo_decode_finished = true;
+	is->m_bvideo_decode_finished = true;
 
     return 0;
 }
@@ -253,13 +241,13 @@ static void video_display(player_stat_t *is)
     // stride/pitch: 一行图像所占的字节数,Stride=BytesPerPixel*Width+Padding,注意对齐
     // AVFrame.*data[]: 每个数组元素指向对应plane
     // AVFrame.linesize[]: 每个数组元素表示对应plane中一行图像所占的字节数
-    sws_scale(is->img_convert_ctx[is->icurrent_index],                    // sws context
+    sws_scale(is->m_pimg_convert_ctx[is->m_icurrent_index],                    // sws context
               (const uint8_t *const *)vp->frame->data,			 // src slice
               vp->frame->linesize,								 // src stride
               0,												 // src slice y
-              is->p_vcodec_ctx[is->icurrent_index]->height,               // src slice height
-              is->p_frm_yuv[is->icurrent_index]->data,                    // dst planes
-              is->p_frm_yuv[is->icurrent_index]->linesize                 // dst strides
+              is->m_pvcodec_ctx[is->m_icurrent_index]->height,               // src slice height
+              is->m_pfrm_yuv[is->m_icurrent_index]->data,                    // dst planes
+              is->m_pfrm_yuv[is->m_icurrent_index]->linesize                 // dst strides
              );
 
 	//is->rvc_hostapi->Debug(MEDIA_LOG_DEBUG, "before SDL_WaitEvent %s:%d", __FUNCTION__, __LINE__);
@@ -272,12 +260,12 @@ static void video_display(player_stat_t *is)
 		// 使用新的YUV像素数据更新SDL_Rect
 		SDL_UpdateYUVTexture(is->sdl_video.texture,								// sdl texture
 			                 &is->sdl_video.rect,								// sdl rect
-				             is->p_frm_yuv[is->icurrent_index]->data[0],        // y plane
-					         is->p_frm_yuv[is->icurrent_index]->linesize[0],    // y pitch
-						     is->p_frm_yuv[is->icurrent_index]->data[1],        // u plane
-							 is->p_frm_yuv[is->icurrent_index]->linesize[1],    // u pitch
-							 is->p_frm_yuv[is->icurrent_index]->data[2],        // v plane
-							 is->p_frm_yuv[is->icurrent_index]->linesize[2]     // v pitch
+				             is->m_pfrm_yuv[is->m_icurrent_index]->data[0],        // y plane
+					         is->m_pfrm_yuv[is->m_icurrent_index]->linesize[0],    // y pitch
+						     is->m_pfrm_yuv[is->m_icurrent_index]->data[1],        // u plane
+							 is->m_pfrm_yuv[is->m_icurrent_index]->linesize[1],    // u pitch
+							 is->m_pfrm_yuv[is->m_icurrent_index]->data[2],        // v plane
+							 is->m_pfrm_yuv[is->m_icurrent_index]->linesize[2]     // v pitch
 							);
     
 		//is->rvc_hostapi->Debug(MEDIA_LOG_DEBUG, "SDL_UpdateYUVTexture %s:%d", __FUNCTION__, __LINE__);
@@ -330,7 +318,7 @@ retry:
     }
 
     // 暂停处理:不停播放上一帧图像
-    if (is->paused){
+    if (is->m_ipaused){
         goto display;
 	}
 
@@ -344,7 +332,6 @@ retry:
         // 播放时刻未到,则更新刷新时间remaining_time为当前时刻到下一播放时刻的时间差
         *remaining_time = FFMIN(is->frame_timer + delay - time, *remaining_time);
         // 播放时刻未到,则不播放,直接返回
-		//is->rvc_hostapi->Debug(MEDIA_LOG_DEBUG, "%s:%d", __FUNCTION__, __LINE__);
         return;
     }
     // 更新frame_timer值
@@ -359,7 +346,6 @@ retry:
     if (!isnan(vp->pts)){
         update_video_pts(is, vp->pts, vp->pos, vp->serial); // 更新视频时钟:时间戳、时钟时间
     }
-
     SDL_UnlockMutex(is->video_frm_queue.frame_mutex);
 
     // 是否要丢弃未能及时播放的视频帧
@@ -370,7 +356,6 @@ retry:
         // 当前帧vp未能及时播放,即下一帧播放时刻(is->frame_timer+duration)小于当前系统时刻(time)
         if (time > is->frame_timer + duration){
             frame_queue_next(&is->video_frm_queue);   // 删除上一帧已显示帧,即删除lastvp,读指针加1(从lastvp更新到vp)
-			//is->rvc_hostapi->Debug(MEDIA_LOG_DEBUG, "%s:%d", __FUNCTION__, __LINE__);
             goto retry;
         }
     }
@@ -379,18 +364,18 @@ retry:
     frame_queue_next(&is->video_frm_queue);
 
 display:
-	//SDL_Event rvcevent;
-	//rvcevent.type = REFRESH_EVENT;
-	//SDL_PushEvent(&rvcevent);
-
     video_display(is);                      // 取出当前帧vp(若有丢帧是nextvp)进行播放
 }
 
 
-static uint32_t get_video_playing_wind_flag(eWindType_t eType)
+static uint32_t get_video_playing_wind_flag(m_eWindType_t eType)
 {
 	uint32_t uFlag = SDL_WINDOW_BORDERLESS | SDL_WINDOW_OPENGL | SDL_WINDOW_ALWAYS_ON_TOP | SDL_WINDOW_SKIP_TASKBAR | SDL_WINDOW_POPUP_MENU | SDL_WINDOW_SHOWN;
 
+#ifndef _WIN32
+	uFlag = SDL_WINDOW_OPENGL|SDL_WINDOW_BORDERLESS|SDL_WINDOW_ALWAYS_ON_TOP|SDL_WINDOW_POPUP_MENU;
+#endif
+
 	return uFlag;
 }
 
@@ -400,7 +385,7 @@ static int video_playing_thread(void *arg)
     player_stat_t *is = (player_stat_t *)arg;
     double remaining_time = 0.0;
 
-	uint32_t uWindFlag = get_video_playing_wind_flag(is->eWindType);
+	uint32_t uWindFlag = get_video_playing_wind_flag(is->m_eWindType);
 
 	is->rvc_hostapi->Debug(MEDIA_LOG_DEBUG, "%s:%d %d %d %d %d", __FUNCTION__, __LINE__, 
 		is->iDisplayCx,
@@ -423,8 +408,9 @@ static int video_playing_thread(void *arg)
 		return -1;
 	}
 	else {
-		is->rvc_hostapi->Debug(MEDIA_LOG_ERROR, "SDL Create Window success.");
+		is->rvc_hostapi->Debug(MEDIA_LOG_DEBUG, "SDL Create Window success.");
 		//SDL_HideWindow(is->sdl_video.window);
+#ifdef _WIN32
 		SDL_SysWMinfo info;
 		HWND hwnd;
 		SDL_VERSION(&info.version);
@@ -442,11 +428,10 @@ static int video_playing_thread(void *arg)
 		else {
 			is->rvc_hostapi->Debug(MEDIA_LOG_DEBUG, "SDL_GetWindowWMInfo failed.");
 		}
-	}
+#else
 
-	//if (eFullScreen_Type == is->eWindType) {
-	//	SDL_SetWindowFullscreen(is->sdl_video.window, SDL_WINDOW_FULLSCREEN_DESKTOP);
-	//}
+#endif // _WIN32
+	}
 
 	int cx = 0, cy = 0;
 	SDL_GetWindowPosition(is->sdl_video.window, &cx, &cy);
@@ -455,20 +440,44 @@ static int video_playing_thread(void *arg)
 	// 2. 创建SDL_Renderer
 	//    SDL_Renderer:渲染器
 	int iNum = SDL_GetNumRenderDrivers();
-	is->rvc_hostapi->Debug(MEDIA_LOG_DEBUG, "SDL_GetNumRenderDrivers %d.", iNum);
+	int iRenderindex = -1;
+	static bool blog = true;
+	if (blog) {
+		is->rvc_hostapi->Debug(MEDIA_LOG_INFO, "SDL_GetNumRenderDrivers %d.", iNum);
+	}
+	
 	for (int index = 0; index < iNum; index++){
 		SDL_RendererInfo info = {0};
 		SDL_GetRenderDriverInfo(index, &info);
-		is->rvc_hostapi->Debug(MEDIA_LOG_DEBUG, "%d render driver name is %s.", index, info.name);
+		if (blog) {
+			is->rvc_hostapi->Debug(MEDIA_LOG_INFO, "%d render driver name is %s.", index, info.name);
+		}
+#ifdef _WIN32
+#else
+		if (strstr(info.name, "software")) {
+			iRenderindex = index;
+		}
+#endif // _WIN32
 	}
 
 	//SDL_RendererFlags
-	is->sdl_video.renderer = SDL_CreateRenderer(is->sdl_video.window, -1, 0);
+	is->sdl_video.renderer = SDL_CreateRenderer(is->sdl_video.window, iRenderindex, 
+		SDL_RENDERER_TARGETTEXTURE |
+		SDL_RENDERER_PRESENTVSYNC |
+		SDL_RENDERER_ACCELERATED);
 	if (NULL == is->sdl_video.renderer){
 		is->rvc_hostapi->Debug(MEDIA_LOG_ERROR, "SDL_CreateRenderer() failed: %s", SDL_GetError());
 		return -1;
 	}
 
+	SDL_RendererInfo RenderInfo;
+	SDL_GetRendererInfo(is->sdl_video.renderer, &RenderInfo);
+	if (blog) {
+		is->rvc_hostapi->Debug(MEDIA_LOG_INFO, "render driver name is %s.", RenderInfo.name);
+		is->rvc_hostapi->Debug(MEDIA_LOG_INFO, "render flag is %d.", RenderInfo.flags);
+	}
+	blog = false;
+
 	// 3. 创建SDL_Texture
 	//    一个SDL_Texture对应一帧YUV数据,同SDL 1.x中的SDL_Overlay
 	is->sdl_video.texture = SDL_CreateTexture(is->sdl_video.renderer,
@@ -485,17 +494,12 @@ static int video_playing_thread(void *arg)
 
 	SDL_ShowWindow(is->sdl_video.window);
 
-	SDL_Surface* screensurface = SDL_GetWindowSurface(is->sdl_video.window);
-
-	//is->rvc_hostapi->Debug(MEDIA_LOG_DEBUG, "%s:%d.", __FUNCTION__, __LINE__);
-
-    while ((false == is->buser_stop) && (false == is->bvideo_decode_finished)){
+    while ((false == is->buser_stop) && (false == is->m_bvideo_decode_finished)){
         if (remaining_time > 0.0){
             av_usleep((unsigned)(remaining_time * 1000000.0));
         }
         remaining_time = REFRESH_RATE;
 
-		//is->rvc_hostapi->Debug(MEDIA_LOG_DEBUG, "%s:%d.", __FUNCTION__, __LINE__);
         // 立即显示当前帧,或延时remaining_time后再显示
         video_refresh(is, &remaining_time);
 		//remaining_time += 0.020;
@@ -525,24 +529,24 @@ static int open_video_playing(void* arg)
 	uint8_t* buffer = NULL;
 	//SDL_Surface* IconSurface = NULL;
 
-	for (size_t index = 0; index < is->uFilesCount; index++) {
-		is->p_frm_yuv[index] = av_frame_alloc();
-		if (NULL == is->p_frm_yuv[index]) {
+	for (size_t index = 0; index < is->m_uFilesCount; index++) {
+		is->m_pfrm_yuv[index] = av_frame_alloc();
+		if (NULL == is->m_pfrm_yuv[index]) {
 			is->rvc_hostapi->Debug(MEDIA_LOG_ERROR, "av_frame_alloc() for p_frm_raw failed");
 			return -1;
 		}
 
 		int iplay_video_width = 0;
-		if (NULL != is->p_vcodec_ctx[index]){
-			iplay_video_width = is->p_vcodec_ctx[index]->width;
+		if (NULL != is->m_pvcodec_ctx[index]){
+			iplay_video_width = is->m_pvcodec_ctx[index]->width;
 		}
 		
 		int iplay_video_height = 0;
-		if (NULL != is->p_vcodec_ctx[index]){
-			iplay_video_height = is->p_vcodec_ctx[index]->height;
+		if (NULL != is->m_pvcodec_ctx[index]){
+			iplay_video_height = is->m_pvcodec_ctx[index]->height;
 		}
 		
-		if (eFullScreen_Type == is->eWindType || eSpecified_Type == is->eWindType) {
+		if (eFullScreen_Type == is->m_eWindType || eSpecified_Type == is->m_eWindType) {
 			iplay_video_width = is->iDisplayWidth;
 			iplay_video_height = is->iDisplayHeight;
 		}
@@ -561,11 +565,11 @@ static int open_video_playing(void* arg)
 			return -1;
 		}
 
-		is->p_video_buffer[index] = buffer;
-		// 使用给定参数设定p_frm_yuv->data和p_frm_yuv->linesize
-		ret = av_image_fill_arrays(is->p_frm_yuv[index]->data,     // dst data[]
-			is->p_frm_yuv[index]->linesize,						   // dst linesize[]
-			is->p_video_buffer[index],							   // src buffer
+		is->m_pvideo_buffer[index] = buffer;
+		// 使用给定参数设定m_pfrm_yuv->data和m_pfrm_yuv->linesize
+		ret = av_image_fill_arrays(is->m_pfrm_yuv[index]->data,     // dst data[]
+			is->m_pfrm_yuv[index]->linesize,						   // dst linesize[]
+			is->m_pvideo_buffer[index],							   // src buffer
 			AV_PIX_FMT_YUV420P,									   // pixel format
 			iplay_video_width,									   // width
 			iplay_video_height,									   // height
@@ -583,9 +587,9 @@ static int open_video_playing(void* arg)
 		//     如果解码后得到图像的不被SDL支持,不进行图像转换的话,SDL是无法正常显示图像的
 		//     如果解码后得到图像的能被SDL支持,则不必进行图像转换
 		//     这里为了编码简便,统一转换为SDL支持的格式AV_PIX_FMT_YUV420P==>SDL_PIXELFORMAT_IYUV
-		is->img_convert_ctx[index] = sws_getContext(is->p_vcodec_ctx[index]->width,   // src width
-			is->p_vcodec_ctx[index]->height,  // src height
-			is->p_vcodec_ctx[index]->pix_fmt, // src format
+		is->m_pimg_convert_ctx[index] = sws_getContext(is->m_pvcodec_ctx[index]->width,   // src width
+			is->m_pvcodec_ctx[index]->height,  // src height
+			is->m_pvcodec_ctx[index]->pix_fmt, // src format
 			iplay_video_width,			// dst width
 			iplay_video_height,			// dst height
 			AV_PIX_FMT_YUV420P,        // dst format
@@ -595,12 +599,12 @@ static int open_video_playing(void* arg)
 			NULL                       // param
 		);
 
-		if (NULL == is->img_convert_ctx[index]) {
+		if (NULL == is->m_pimg_convert_ctx[index]) {
 			is->rvc_hostapi->Debug(MEDIA_LOG_ERROR, "sws_getContext() failed.");
 			return -1;
 		}
 		else {
-			is->rvc_hostapi->Debug(MEDIA_LOG_DEBUG, "%s:%d is->img_convert_ctx[%d] = 0x%08x.", __FUNCTION__, __LINE__, index, is->img_convert_ctx[index]);
+			is->rvc_hostapi->Debug(MEDIA_LOG_DEBUG, "%s:%d is->m_pimg_convert_ctx[%d] = 0x%08x.", __FUNCTION__, __LINE__, index, is->m_pimg_convert_ctx[index]);
 		}
 
 		// SDL_Rect赋值
@@ -609,7 +613,7 @@ static int open_video_playing(void* arg)
 		is->sdl_video.rect.w = iplay_video_width;
 		is->sdl_video.rect.h = iplay_video_height;
 
-		//uint32_t uWindFlag = get_video_playing_wind_flag(is->eWindType);
+		//uint32_t uWindFlag = get_video_playing_wind_flag(is->m_eWindType);
 
 		//is->rvc_hostapi->Debug(MEDIA_LOG_DEBUG, "%s:%d %d %d %d %d", __FUNCTION__, __LINE__, 
 		//is->iDisplayCx,
@@ -640,7 +644,7 @@ static int open_video_playing(void* arg)
 		//	//SDL_UpdateWindowSurface(is->sdl_video.window);
 		//}
 
-		//if (eFullScreen_Type == is->eWindType) {
+		//if (eFullScreen_Type == is->m_eWindType) {
 		//	SDL_SetWindowFullscreen(is->sdl_video.window, SDL_WINDOW_FULLSCREEN_DESKTOP);
 		//}
 
@@ -648,10 +652,10 @@ static int open_video_playing(void* arg)
 		//SDL_GetWindowPosition(is->sdl_video.window, &cx, &cy);
 		//is->rvc_hostapi->Debug(MEDIA_LOG_DEBUG, "window flag is 0x%08x, cx = %d, cy = %d.", SDL_GetWindowFlags(is->sdl_video.window), cx, cy);
 
-		////if (NULL != is->piconpath) {
-		////	IconSurface = SDL_LoadBMP(is->piconpath);
+		////if (NULL != is->m_piconpath) {
+		////	IconSurface = SDL_LoadBMP(is->m_piconpath);
 		////	if (NULL == IconSurface) {
-		////		is->rvc_hostapi->Debug(MEDIA_LOG_ERROR, "SDL_LoadBMP(%s) failed: %s", is->piconpath, SDL_GetError());
+		////		is->rvc_hostapi->Debug(MEDIA_LOG_ERROR, "SDL_LoadBMP(%s) failed: %s", is->m_piconpath, SDL_GetError());
 		////	}
 		////	else {
 		////		SDL_SetWindowIcon(is->sdl_video.window, IconSurface);
@@ -692,13 +696,13 @@ static int open_video_playing(void* arg)
 
 		//SDL_ShowWindow(is->sdl_video.window);
 
-		is->video_playing_tid = SDL_CreateThread(video_playing_thread, "video playing thread", is);
-		if (NULL == is->video_playing_tid) {
+		is->m_video_playing_tid = SDL_CreateThread(video_playing_thread, "video playing thread", is);
+		if (NULL == is->m_video_playing_tid) {
 			is->rvc_hostapi->Debug(MEDIA_LOG_ERROR, "SDL_Create video playing thread failed: %s.", SDL_GetError());
 			return -1;
 		}
 		else {
-			is->rvc_hostapi->Debug(MEDIA_LOG_DEBUG, "create %s success, and thread id is %u.", SDL_GetThreadName(is->video_playing_tid), SDL_GetThreadID(is->video_playing_tid));
+			is->rvc_hostapi->Debug(MEDIA_LOG_DEBUG, "create %s success, and thread id is %u.", SDL_GetThreadName(is->m_video_playing_tid), SDL_GetThreadID(is->m_video_playing_tid));
 		}
 	}
 
@@ -712,8 +716,8 @@ static int open_video_stream(player_stat_t *is)
     AVCodecContext* p_codec_ctx = NULL;
 	int ret = -1;
 
-	for (size_t index = 0; index < is->uFilesCount; index++){
-		AVStream* p_stream = is->p_video_stream[index];
+	for (size_t index = 0; index < is->m_uFilesCount; index++){
+		AVStream* p_stream = is->m_pvideo_stream[index];
 
 		// 1. 为视频流构建解码器AVCodecContext
 		// 1.1 获取解码器参数AVCodecParameters
@@ -737,25 +741,29 @@ static int open_video_stream(player_stat_t *is)
 		ret = avcodec_parameters_to_context(p_codec_ctx, p_codec_par);
 		if (ret < 0) {
 			is->rvc_hostapi->Debug(MEDIA_LOG_ERROR, "avcodec_parameters_to_context() failed");
+			avcodec_close(p_codec_ctx);
+			avcodec_free_context(&p_codec_ctx);
 			return ret;
 		}
 		// 1.3.3 p_codec_ctx初始化:使用p_codec初始化p_codec_ctx,初始化完成
 		ret = avcodec_open2(p_codec_ctx, p_codec, NULL);
 		if (ret < 0) {
 			is->rvc_hostapi->Debug(MEDIA_LOG_ERROR, "avcodec_open2() failed %d", ret);
+			avcodec_close(p_codec_ctx);
+			avcodec_free_context(&p_codec_ctx);
 			return ret;
 		}
-		is->p_vcodec_ctx[index] = p_codec_ctx;
+		is->m_pvcodec_ctx[index] = p_codec_ctx;
 	}
 
     // 2. 创建视频解码线程
-	is->video_decode_tid = SDL_CreateThread(video_decode_thread, "video decode thread", is);
-	if (NULL == is->video_decode_tid) {
+	is->m_video_decode_tid = SDL_CreateThread(video_decode_thread, "video decode thread", is);
+	if (NULL == is->m_video_decode_tid) {
 		is->rvc_hostapi->Debug(MEDIA_LOG_ERROR, "SDL_Create video decode thread failed: %s.", SDL_GetError());
 		return -1;
 	}
 	else {
-		is->rvc_hostapi->Debug(MEDIA_LOG_DEBUG, "create %s success, and thread id is %u.", SDL_GetThreadName(is->video_decode_tid), SDL_GetThreadID(is->video_decode_tid));
+		is->rvc_hostapi->Debug(MEDIA_LOG_DEBUG, "create %s success, and thread id is %u.", SDL_GetThreadName(is->m_video_decode_tid), SDL_GetThreadID(is->m_video_decode_tid));
 	}
 
     return 0;

+ 0 - 0
Other/unix/libmediaplayer/video.h → Other/libmediaplayer/video.h


+ 6 - 5
Other/win/libpictureplayer/CMakeLists.txt → Other/libpictureplayer/CMakeLists.txt

@@ -9,23 +9,24 @@ set(${MODULE_PREFIX}_SRCS
 	libpictureplayer.cpp
 )
 
+
 add_library(${MODULE_NAME} SHARED ${${MODULE_PREFIX}_SRCS})
 
-message(STATUS "CONAN_INCLUDE_DIRS_SDL2 :${CONAN_INCLUDE_DIRS_SDL2}")
 
 target_include_directories(${MODULE_NAME} PRIVATE
 	${RVC_COMMON_INCLUDE_DIR}
 	${CONAN_INCLUDE_DIRS_SDL2}
-	)
+)
 
 
 target_link_directories(${MODULE_NAME} PRIVATE
 	${CONAN_LIB_DIRS_SDL2}
-	)
+)
+
 
-target_link_libraries(${MODULE_NAME} PRIVATE ${${MODULE_PREFIX}_LIBS}	PRIVATE
+target_link_libraries(${MODULE_NAME} PRIVATE ${${MODULE_PREFIX}_LIBS} PRIVATE
 	${CONAN_LIBS_SDL2}
-	)  
+)  
 
 
 target_compile_definitions(${MODULE_NAME} PUBLIC "LIBPICTUREPLAYER_EXPORTS")

+ 105 - 26
Other/win/libpictureplayer/CPicturePlayer.cpp → Other/libpictureplayer/CPicturePlayer.cpp

@@ -1,14 +1,33 @@
 #include <stdio.h>
-//#include <stdbool.h>
+#include <stdbool.h>
 #include <assert.h>
 #include <string.h>
 #include <time.h>
 #include <errno.h>
-
 #include "CPicturePlayer.h"
 
-#define SAFE_DELETE(p)       { if(p) { delete (p);     (p)=NULL; } }
-#define SAFE_DELETE_ARRAY(p) { if(p) { delete[] (p);   (p)=NULL; } }
+
+#ifndef SAFE_DELETE
+#define SAFE_DELETE(p)	\
+	do{\
+		 if(p) { \
+			delete p; \
+			p = NULL; \
+		 } \
+	} while (0)
+#endif
+
+
+#ifndef SAFE_DELETE_ARRAY
+#define SAFE_DELETE_ARRAY(p)	\
+	do{ \
+		if(p) { \
+			delete[] (p); \
+			(p)=NULL; \
+		}\
+	}while(0)
+#endif
+
 
 static char* rvc_strdup(const char* strdata)
 {
@@ -38,7 +57,7 @@ static void rvc_strfree(char* strdata)
 	}
 }
 
-
+#ifdef _WIN32
 static char* GB2312ToUtf8(const char* gb2312)
 {
 	int len = MultiByteToWideChar(CP_ACP, 0, gb2312, -1, NULL, 0);
@@ -52,7 +71,7 @@ static char* GB2312ToUtf8(const char* gb2312)
 	if(wstr) delete[] wstr;
 	return str;
 }
-
+#endif
 
 CPicturePlayer::CPicturePlayer(CPicHostApi* pHostApi)
 {
@@ -64,7 +83,6 @@ CPicturePlayer::CPicturePlayer(CPicHostApi* pHostApi)
 	m_nplay_cnt = 0;
 	m_nplay_interval = 5000;
 	m_stricopath = NULL;
-	m_play_exit_event = NULL;
 	memset(m_strroot_path, 0, MAX_PATH);
 	for (size_t i = 0; i < MAX_FILECOUNT; i++){
 		memset(m_strfile_names[i], 0, MAX_PATH);
@@ -135,23 +153,34 @@ int CPicturePlayer::InitParam(rvc_picture_player_param_t* tparam)
 	//	return iRet;
 	//}
 
-	//sem_init(&m_play_exit_sem, 0, 0);
+#ifdef _WIN32
 	m_play_exit_event = CreateEventA(NULL, FALSE, FALSE, NULL);
+#else
+	sem_init(&m_play_exit_sem, 0, 0);
+#endif
 	m_busrstop = false;
 
 	m_nfile_cnt = tparam->nfile_cnt;
 	m_nplay_cnt = tparam->nplay_cnt;
 	m_nplay_interval = tparam->nplay_interval;
+#ifdef _WIN32
 	_snprintf(m_strroot_path, MAX_PATH, "%s", tparam->strroot_path);
 	for (size_t index = 0; index < m_nfile_cnt; index++) {
 		_snprintf(m_strfile_names[index], MAX_PATH, "%s", tparam->strfile_names[index]);
 	}
 
 	m_uflag = SDL_WINDOW_BORDERLESS | SDL_WINDOW_OPENGL | SDL_WINDOW_ALWAYS_ON_TOP | SDL_WINDOW_SKIP_TASKBAR | SDL_WINDOW_POPUP_MENU;
-	//if (tparam->bfull_screen) {
-	//	m_uflag += SDL_WINDOW_FULLSCREEN;
-	//}
+#else
+	snprintf(m_strroot_path, MAX_PATH, "%s", tparam->strroot_path);
+	for (size_t index = 0; index < m_nfile_cnt; index++) {
+		snprintf(m_strfile_names[index], MAX_PATH, "%s", tparam->strfile_names[index]);
+	}
 
+	m_uflag = SDL_WINDOW_SHOWN|SDL_WINDOW_BORDERLESS|SDL_WINDOW_ALWAYS_ON_TOP|SDL_WINDOW_POPUP_MENU;
+	if (tparam->bfull_screen) {
+		m_uflag += SDL_WINDOW_FULLSCREEN;
+	}
+#endif
 	size_t uVideoPlayNum = GetVideoDisplayInfo();
 
 	m_idispalycx = 0;
@@ -192,11 +221,15 @@ int CPicturePlayer::DeInit()
 	m_show_width = 0;
 	m_show_height = 0;
 	m_busrstop = false;
-	//sem_destroy(&m_play_exit_sem);
+
+#ifdef _WIN32
 	if (NULL != m_play_exit_event){
 		CloseHandle(m_play_exit_event);
 		m_play_exit_event = NULL;
 	}
+#else
+	sem_destroy(&m_play_exit_sem);
+#endif
 
 	if (NULL != m_window) {
 		SDL_DestroyWindow(m_window);
@@ -214,9 +247,6 @@ bool CPicturePlayer::StartPicPlay()
 {
 	bool bRet = false;
 
-	SDL_SysWMinfo info;
-	HWND hwnd;
-
 	//1.创建播放窗体
 	m_window = SDL_CreateWindow("picture player",
 		m_idispalycx,
@@ -240,8 +270,12 @@ bool CPicturePlayer::StartPicPlay()
 
 	m_pHostApi->PicDebug(PIC_LOG_DEBUG, "set m_bplaying = true");
 
+#ifdef _WIN32
+	SDL_SysWMinfo info;
+	HWND hwnd;
+	
 	SDL_VERSION(&info.version);
-	if (SDL_GetWindowWMInfo(m_window, &info)){
+	if (SDL_GetWindowWMInfo(m_window, &info)) {
 		hwnd = info.info.win.window;
 		m_pHostApi->PicDebug(PIC_LOG_DEBUG, "SDL_GetWindowWMInfo success.");
 		SetWindowPos(hwnd,
@@ -251,10 +285,11 @@ bool CPicturePlayer::StartPicPlay()
 			m_show_width,
 			m_show_height,
 			SWP_NOMOVE | SWP_NOSIZE);
-	}
+}
 	else {
 		m_pHostApi->PicDebug(PIC_LOG_DEBUG, "SDL_GetWindowWMInfo failed.");
 	}
+#endif // _WIN32
 
 	SDL_Surface* surface = SDL_GetWindowSurface(m_window);
 
@@ -271,16 +306,27 @@ bool CPicturePlayer::StartPicPlay()
 			if (m_busrstop) {
 				break;
 			}
-			
+
+			SDL_Surface* image = NULL;
+		#ifdef _WIN32
 			char* strfilename = GB2312ToUtf8(m_strfile_names[index]);
-			SDL_Surface* image = IMG_Load(strfilename);
-			SAFE_DELETE_ARRAY(strfilename)
+			image = IMG_Load(strfilename);
+			SAFE_DELETE_ARRAY(strfilename);
+		#else
+			image = IMG_Load(m_strfile_names[index]);
+		#endif
 
 			if (NULL == image) {
 				m_pHostApi->PicDebug(PIC_LOG_ERROR, "IMG_Load %s failed!", m_strfile_names[index]);
+
+			#ifdef _WIN32
 				strfilename = GB2312ToUtf8(m_strfile_names[index]);
 				image = SDL_LoadBMP(strfilename);
-				SAFE_DELETE_ARRAY(strfilename)
+				SAFE_DELETE_ARRAY(strfilename);
+			#else
+				image = SDL_LoadBMP(m_strfile_names[index]);
+			#endif
+
 				if (NULL == image) {
 					continue;
 				}
@@ -295,11 +341,12 @@ bool CPicturePlayer::StartPicPlay()
 			dst.w = m_show_width;
 			dst.h = m_show_height;
 
-			int itimems = m_nplay_interval;
+			int itimes = m_nplay_interval;
 			SDL_BlitSurface(image, NULL, surface, &dst);
+#ifdef _WIN32
 			DWORD t1 = 0,t2 = 0;
 			t1 = GetTickCount();
-			while(itimems > 0){
+			while(itimes > 0){
 				DWORD dwRet = WaitForSingleObject(m_play_exit_event, 10);
 				if (dwRet == WAIT_TIMEOUT){
 
@@ -313,11 +360,11 @@ bool CPicturePlayer::StartPicPlay()
 
 					SDL_UpdateWindowSurface(m_window);
 
-					itimems--;
+					itimes--;
 
 					t2 = GetTickCount();
 					if (t2 - t1 > m_nplay_interval){
-						m_pHostApi->PicDebug(PIC_LOG_DEBUG, "%s:%d it's time to leave and itimems is %d.", __FUNCTION__, __LINE__, itimems);
+						m_pHostApi->PicDebug(PIC_LOG_DEBUG, "%s:%d it's time to leave and itimems is %d.", __FUNCTION__, __LINE__, itimes);
 						break;
 					}
 				}
@@ -327,6 +374,32 @@ bool CPicturePlayer::StartPicPlay()
 					break;
 				}
 			}
+#else
+			SDL_UpdateWindowSurface(m_window);
+			struct timespec ts;
+			m_pHostApi->PicDebug(PIC_LOG_DEBUG, "%s:%d itimes = %d.", __FUNCTION__, __LINE__, itimes);
+
+			clock_gettime(CLOCK_REALTIME, &ts);
+			if (itimes > 1000){
+				ts.tv_sec += (itimes / 1000);
+				itimes = m_nplay_interval % 1000;
+			}
+			
+			long unsec = ts.tv_nsec + (1000 * 1000 * itimes);
+			ts.tv_sec += (unsec / 1000000000);
+			ts.tv_nsec = (unsec % 1000000000);
+
+			if (-1 == sem_timedwait(&m_play_exit_sem, &ts)) {
+				if (ETIMEDOUT == errno) {
+
+				}
+			}
+			else {
+				m_pHostApi->PicDebug(PIC_LOG_DEBUG, "%s:%d break circle.", __FUNCTION__, __LINE__);
+				SDL_Delay(200);
+				break;
+			}
+#endif
 
 			SDL_FreeSurface(surface);
 			SDL_FreeSurface(image);
@@ -340,6 +413,7 @@ bool CPicturePlayer::StartPicPlay()
 		m_pHostApi->PicDebug(PIC_LOG_INFO, "user stop picture playing task, exit.");
 	}
 
+	SDL_HideWindow(m_window);
 	SDL_DestroyWindow(m_window);
 	m_window = NULL;
 	bRet = true;
@@ -351,8 +425,13 @@ bool CPicturePlayer::StartPicPlay()
 int CPicturePlayer::StopPicPlay()
 {
 	int iRet = -1;
-	//sem_post(&m_play_exit_sem);
+
+#ifdef _WIN32
 	SetEvent(m_play_exit_event);
+#else
+	sem_post(&m_play_exit_sem);
+#endif
+
 	m_busrstop = true;
 	m_pHostApi->PicDebug(PIC_LOG_DEBUG, "stop picture play, set user stop flag true.");
 

+ 12 - 4
Other/win/libpictureplayer/CPicturePlayer.h → Other/libpictureplayer/CPicturePlayer.h

@@ -3,9 +3,13 @@
 
 #include <stdio.h>
 #include <stdint.h>
-//#include <stdbool.h>
-//#include <semaphore.h>
+
+#ifdef _WIN32
 #include <Windows.h>
+#else
+#include <stdbool.h>
+#include <semaphore.h>
+#endif
 
 #include "ipicdatastruct.h"
 
@@ -14,7 +18,7 @@ extern "C"
 {
 #endif // __cplusplus
 
-#if defined(_WIN32)
+#ifdef _WIN32
 #include <SDL.h>
 #include <SDL_video.h>
 #include <SDL_render.h>
@@ -97,8 +101,12 @@ private:
 	char* m_stricopath;
 	SDL_Thread* m_thid;
 	SDL_DisplayMode m_dispalymode[MAX_DISPLAYNUM];
-	//sem_t m_play_exit_sem;
+
+#ifdef _WIN32
 	HANDLE m_play_exit_event;
+#else
+	sem_t m_play_exit_sem;
+#endif
 };
 
 

+ 1 - 1
Other/win/libpictureplayer/ipicdatastruct.h → Other/libpictureplayer/ipicdatastruct.h

@@ -48,7 +48,7 @@ struct RVC_NO_VTABLE CPicHostApi
 {
 	virtual void PicDebug(pic_loglevel elvel, const char* fmt, ...) = 0;
 	virtual int LoadPlayConfig(CPicPlayConfig& config, int CfgInx = 0) = 0;
-	virtual int GetPicPlayerIcoPath(char* strPath, size_t uLen) = 0;
+	virtual int GetPicPlayerIcoPath(char* strPath, int iLen) = 0;
 };
 
 #endif

+ 97 - 22
Other/unix/libpictureplayer/libpictureplayer.cpp → Other/libpictureplayer/libpictureplayer.cpp

@@ -1,11 +1,41 @@
 #include "libpictureplayer.h"
 #include "CPicturePlayer.h"
-#include <unistd.h>
 #include <string.h>
+#ifdef _WIN32
+#include <process.h>
+#include <io.h>
+#else
+#include <unistd.h>
 #include <pthread.h>
+#endif
+
+#ifndef RVC_DEFAULT_PIC_WIDTH
+#define RVC_DEFAULT_PIC_WIDTH 1920
+#endif // !RVC_DEFAULT_PIC_WIDTH
+
+#ifndef RVC_DEFAULT_PIC_HEIGHT
+#define RVC_DEFAULT_PIC_HEIGHT 1080
+#endif // !RVC_DEFAULT_PIC_HEIGHT
+
+#ifdef _WIN32
+static unsigned int __stdcall PicturePlayingFunc(void* param)
+#else
+static void* PicturePlayingFunc(void* param) 
+#endif 
+{
+	CPicturePlayer* is = (CPicturePlayer*)param;
+
+	is->m_pHostApi->PicDebug(PIC_LOG_DEBUG, "enter PicturePlayingFunc");
+
+	is->StartPicPlay();
+
+	is->SetPicPlayingFlag(false);
 
+	is->m_pHostApi->PicDebug(PIC_LOG_DEBUG, "leave PicturePlayingFunc");
+
+	return 0;
+}
 
-void* PicturePlayingFunc(void* param);
 
 class libpictureplayer_impl
 {
@@ -14,7 +44,11 @@ public:
 	CPicHostApi* m_pHostApi;
 	CPicturePlayer* m_Player;
 	bool m_bIsPlay;
+#ifdef _WIN32
+	HANDLE m_PlayThread;
+#else
 	pthread_t m_PlayThreadId;
+#endif
 
 public:
 	libpictureplayer_impl(CPicHostApi* pHostApi) {
@@ -25,7 +59,11 @@ public:
 		if (NULL == m_Player) {
 			pHostApi->PicDebug(PIC_LOG_DEBUG, "new PicturePlayer failed!");
 		}
+#ifdef _WIN32
+		m_PlayThread = NULL;
+#else
 		m_PlayThreadId = 0;
+#endif
 	}
 
 	~libpictureplayer_impl()
@@ -34,7 +72,11 @@ public:
 		delete m_Player;
 		m_Player = NULL;
 		m_bIsPlay = false;
+#ifdef _WIN32
+		m_PlayThread = NULL;
+#else
 		m_PlayThreadId = 0;
+#endif
 	}
 
 	bool isStop() 
@@ -46,12 +88,21 @@ public:
 	bool CheckIsPlay(void* pthreadid)
 	{
 		bool bret = false;
+#ifdef _WIN32
+		HANDLE threadHandle = m_PlayThread;
+		if (NULL != threadHandle)
+		{
+			bret = true;
+			*(HANDLE*)pthreadid = threadHandle;
+		}
+#else
 		int64_t iThreadId = m_PlayThreadId;
 		if (0 != iThreadId)
 		{
 			bret = true;
 			*(int64_t*)pthreadid = iThreadId;
 		}
+#endif
 
 		return bret;
 	}
@@ -68,15 +119,19 @@ public:
 		rvc_picture_player_param_t tplayer_param = { 0 };
 		tplayer_param.icx = m_stPlayConfig.nWndX;
 		tplayer_param.icy = m_stPlayConfig.nWndY;
-		tplayer_param.uwindow_width = m_stPlayConfig.nWndWidth;
-		tplayer_param.uwindow_height = m_stPlayConfig.nWndHeight;
+		tplayer_param.uwindow_width = m_stPlayConfig.nWndWidth > 0 ? m_stPlayConfig.nWndWidth : RVC_DEFAULT_PIC_WIDTH;
+		tplayer_param.uwindow_height = m_stPlayConfig.nWndHeight > 0 ? m_stPlayConfig.nWndHeight : RVC_DEFAULT_PIC_HEIGHT;
 
 		tplayer_param.bfull_screen = m_stPlayConfig.bFullScreen;
 		tplayer_param.nplay_cnt = m_stPlayConfig.nPlayCnt;
 		tplayer_param.nplay_interval = m_stPlayConfig.nPlayInterval;
 
 		char strFileName[MAX_PATH] = { 0 };
+	#ifdef _WIN32
+		_snprintf(strFileName, MAX_PATH, "%s%s", m_stPlayConfig.strRootPath, m_stPlayConfig.strFileNames[0]);
+	#else
 		snprintf(strFileName, MAX_PATH, "%s%s", m_stPlayConfig.strRootPath, m_stPlayConfig.strFileNames[0]);
+	#endif
 		if (IsFileExist(strFileName)) {
 			memcpy(tplayer_param.strfile_names[0], strFileName, strlen(strFileName));
 			tplayer_param.nfile_cnt = 1;
@@ -92,6 +147,18 @@ public:
 			if (0 == m_Player->InitParam(&tplayer_param))
 			{
 				m_pHostApi->PicDebug(PIC_LOG_DEBUG, "init picture player success and begin start picture play.");
+			#ifdef _WIN32
+				m_PlayThread = (HANDLE)_beginthreadex(NULL, 0, &PicturePlayingFunc, m_Player, 0, NULL);
+				if (NULL != m_PlayThread) {
+					m_pHostApi->PicDebug(PIC_LOG_DEBUG, "create picture play thread success.");
+					m_bIsPlay = true;
+					bRet = true;
+					m_pHostApi->PicDebug(PIC_LOG_DEBUG, "start picture play Success.");
+				}
+				else {
+					m_pHostApi->PicDebug(PIC_LOG_DEBUG, "create picture play thread failed.");
+				}
+			#else
 				int err = pthread_create(&m_PlayThreadId, NULL, PicturePlayingFunc, m_Player);
 				if (0 == err) {
 					m_pHostApi->PicDebug(PIC_LOG_DEBUG, "create picture play thread[%u] success.", m_PlayThreadId);
@@ -102,6 +169,7 @@ public:
 				else {
 					m_pHostApi->PicDebug(PIC_LOG_DEBUG, "create picture play thread failed.");
 				}
+			#endif
 			}
 			else {
 				m_pHostApi->PicDebug(PIC_LOG_ERROR, "init picture player failed!");
@@ -128,7 +196,11 @@ public:
 		size_t uValidCount = 0;
 		for (int i = 0; i < m_stPlayConfig.nFileCnt && i < MAX_FILECOUNT; i++) {
 			char strFileName[MAX_PATH] = { 0 };
-			snprintf(strFileName, MAX_PATH, "%s%s", m_stPlayConfig.strRootPath, m_stPlayConfig.strFileNames[i]);
+	#ifdef _WIN32
+		_snprintf(strFileName, MAX_PATH, "%s%s", m_stPlayConfig.strRootPath, m_stPlayConfig.strFileNames[i]);
+	#else
+		snprintf(strFileName, MAX_PATH, "%s%s", m_stPlayConfig.strRootPath, m_stPlayConfig.strFileNames[i]);
+	#endif
 			if (IsFileExist(strFileName)) {
 				memcpy(pParam->strfile_names[i], strFileName, strlen(strFileName));
 				uValidCount++;
@@ -140,7 +212,7 @@ public:
 		}
 		pParam->nfile_cnt = uValidCount;
 		if (NULL != m_pHostApi) {
-			m_pHostApi->PicDebug(PIC_LOG_DEBUG, "pParam uFilesCount = %d", uValidCount);
+			m_pHostApi->PicDebug(PIC_LOG_DEBUG, "pParam m_uFilesCount = %d", uValidCount);
 		}
 		if (uValidCount > 0) {
 			iRet = 0;
@@ -183,6 +255,18 @@ public:
 			{
 				m_pHostApi->PicDebug(PIC_LOG_DEBUG, "init picture player Success.");
 				m_pHostApi->PicDebug(PIC_LOG_DEBUG, "start picture play success.");
+			#ifdef _WIN32
+				m_PlayThread = (HANDLE)_beginthreadex(NULL, 0, &PicturePlayingFunc, m_Player, 0, NULL);
+				if (NULL != m_PlayThread) {
+					m_pHostApi->PicDebug(PIC_LOG_DEBUG, "create picture play thread success.");
+					m_bIsPlay = true;
+					bRet = true;
+					m_pHostApi->PicDebug(PIC_LOG_DEBUG, "start picture play success.");
+				}
+				else {
+					m_pHostApi->PicDebug(PIC_LOG_DEBUG, "create picture play thread failed.");
+				}
+			#else
 				int err = pthread_create(&m_PlayThreadId, NULL, PicturePlayingFunc, m_Player);
 				if (0 == err) {
 					m_pHostApi->PicDebug(PIC_LOG_DEBUG, "create picture play thread[%u] success.", m_PlayThreadId);
@@ -193,6 +277,7 @@ public:
 				else {
 					m_pHostApi->PicDebug(PIC_LOG_DEBUG, "create picture play thread failed.");
 				}
+			#endif
 			}
 		}
 		else {
@@ -223,9 +308,15 @@ public:
 	{
 		bool bRet = false;
 		if (NULL != pFilePath) {
+	#ifdef _WIN32
+			if (0 == _access(pFilePath, 0)) {
+				bRet = true;
+			}
+	#else
 			if (0 == access(pFilePath, F_OK)) {
 				bRet = true;
 			}
+	#endif
 		}
 		return bRet;
 	}
@@ -265,19 +356,3 @@ void Clibpictureplayer::Close()
 {
 	m_pImpl->StopPlay();
 }
-
-
-void* PicturePlayingFunc(void* param) 
-{
-	CPicturePlayer* is = (CPicturePlayer*)param;
-
-	is->m_pHostApi->PicDebug(PIC_LOG_DEBUG, "enter PicturePlayingFunc");
-
-	is->StartPicPlay();
-
-	is->SetPicPlayingFlag(false);
-
-	is->m_pHostApi->PicDebug(PIC_LOG_DEBUG, "leave PicturePlayingFunc");
-
-	return 0;
-}

+ 0 - 0
Other/win/libpictureplayer/libpictureplayer.h → Other/libpictureplayer/libpictureplayer.h


+ 0 - 2
Other/unix/CMakeLists.txt

@@ -9,8 +9,6 @@ add_subdirectory(libfacecapture)
 add_subdirectory(libaudions)
 add_subdirectory(libvideorecord)
 
-add_subdirectory(libpictureplayer)
-add_subdirectory(libmediaplayer)
 add_subdirectory(libmediadeviceinfo)
 add_subdirectory(libvideorender)
 add_subdirectory(libvideocapture)

+ 0 - 73
Other/unix/libmediaplayer/CMakeLists.txt

@@ -1,73 +0,0 @@
-set(MODULE_NAME "mediaplayer")
-set(MODULE_PREFIX "LIB_MEDIAPLAYER_FUNC")
-
-
-set(${MODULE_PREFIX}_SRCS
-	libmediaplayer.h
-	libmediaplayer.cpp
-	player.h
-	player.cpp
-	audio.h
-	audio.cpp
-	demux.h
-	demux.cpp
-	frame.h
-	frame.cpp
-	packet.h
-	packet.cpp
-	video.h
-	video.cpp
-)
-
-add_library(${MODULE_NAME} SHARED ${${MODULE_PREFIX}_SRCS})
-
-
-
-target_include_directories(${MODULE_NAME} PRIVATE
-	${RVC_COMMON_INCLUDE_DIR}
-	${RVC_WINPR_INCLUDE_DIR}
-	${CONAN_INCLUDE_DIRS_FFMPEG}
-	${CONAN_INCLUDE_DIRS_SDL2}
-	)
-
-
-target_link_directories(${MODULE_NAME} PRIVATE
-	${CONAN_LIB_DIRS_FFMPEG}
-	${CONAN_LIB_DIRS_SDL2}
-	)
-
-
-message(STATUS "CONAN_LIBS_FFMPEG== ${CONAN_LIBS_FFMPEG}")
-message(STATUS "CONAN_INCLUDE_DIRS_FFMPEG== ${CONAN_INCLUDE_DIRS_FFMPEG}")
-message(STATUS "CONAN_PKG_LIBS_FFMPEG== ${CONAN_PKG_LIBS_FFMPEG}")
-message(STATUS "CONAN_LIBS_SDL2 == ${CONAN_LIBS_SDL2}")
-
-target_link_libraries(${MODULE_NAME} PRIVATE ${${MODULE_PREFIX}_LIBS} PRIVATE
-	${CONAN_LIBS_FFMPEG}
-	${CONAN_LIBS_SDL2}
-	)  
-
-target_compile_definitions(${MODULE_NAME} PUBLIC "LIBMEDIAPLAYER_EXPORTS")
-
-
-
-if(MSVC)
-	install(TARGETS ${MODULE_NAME} 
-    RUNTIME DESTINATION "${RVC_RUNTIME_PATH}" COMPONENT libraries
-    ARCHIVE DESTINATION "${RVC_LIBRARY_PATH}" COMPONENT develops EXCLUDE_FROM_ALL
-    LIBRARY DESTINATION "${RVC_LIBRARY_PATH}" COMPONENT libraries
-    )
-else()
-install(TARGETS ${MODULE_NAME} 
-    RUNTIME DESTINATION "${RVC_RUNTIME_PATH}"
-    ARCHIVE DESTINATION "${RVC_LIBRARY_PATH}"
-    LIBRARY DESTINATION "${RVC_RUNTIME_PATH}"
-    COMPONENT libraries)
-endif(MSVC)
-
-# ����Ҫ���������ĵ�������
-if(MSVC)
-set(OTHER_CONAN_DEP_LIBS ${OTHER_CONAN_DEP_LIBS} ${CONAN_BIN_DIRS} PARENT_SCOPE)
-else()
-set(OTHER_CONAN_DEP_LIBS ${OTHER_CONAN_DEP_LIBS} ${CONAN_LIB_DIRS} PARENT_SCOPE)
-ENDIF(MSVC)

+ 0 - 533
Other/unix/libmediaplayer/audio.cpp

@@ -1,533 +0,0 @@
-#include "player.h"
-#include "packet.h"
-#include "frame.h"
-
-static void sdl_audio_callback(void *opaque, uint8_t*stream, int len);
-
-// 从packet_queue中取一个packet,解码生成frame
-static int audio_decode_frame(AVCodecContext *p_codec_ctx, packet_queue_t *p_pkt_queue, AVFrame *frame, CMediaHostApi* hostapi)
-{
-    int ret = -1;
-	if (NULL == p_codec_ctx){
-		return ret;
-	}
-
-    while (0 == p_pkt_queue->abort_flag)
-    {
-		AVPacket pkt = {0};
-
-        while (0 == p_pkt_queue->abort_flag)
-        {
-            // 3.2 一个音频packet含一至多个音频frame,每次avcodec_receive_frame()返回一个frame,此函数返回。
-            // 下次进来此函数,继续获取一个frame,直到avcodec_receive_frame()返回AVERROR(EAGAIN),
-            // 表示解码器需要填入新的音频packet
-            ret = avcodec_receive_frame(p_codec_ctx, frame);
-            if (ret >= 0)
-            {
-                // 时基转换,从d->avctx->pkt_timebase时基转换到1/frame->sample_rate时基
-				AVRational tb{ 1, frame->sample_rate };
-                if (frame->pts != AV_NOPTS_VALUE)
-                {
-                    frame->pts = av_rescale_q(frame->pts, p_codec_ctx->pkt_timebase, tb);
-                }
-                else
-                {
-					//hostapi->Debug(MEDIA_LOG_DEBUG, "frame->pts no.");
-                }
-
-                return 1;
-            }
-            else if (ret == AVERROR_EOF)
-            {
-                avcodec_flush_buffers(p_codec_ctx);
-                return -1;
-            }
-            else if (ret == AVERROR(EAGAIN))
-            {
-				break;
-            }
-            else
-            {
-				hostapi->Debug(MEDIA_LOG_DEBUG, "audio avcodec_receive_frame(): other errors.");
-				continue;
-            }
-        }
-
-        // 1. 取出一个packet。使用pkt对应的serial赋值给d->pkt_serial
-        if (packet_queue_get(p_pkt_queue, &pkt, true) < 0)
-        {
-			hostapi->Debug(MEDIA_LOG_DEBUG, "packet_queue_get return -1 exit audio_decode_frame function.");
-            return -1;
-        }
-
-        // packet_queue中第一个总是flush_pkt。每次seek操作会插入flush_pkt,更新serial,开启新的播放序列
-        if (NULL == pkt.data || 0 == pkt.size)
-        {
-            // 复位解码器内部状态/刷新内部缓冲区。当seek操作或切换流时应调用此函数。
-            avcodec_flush_buffers(p_codec_ctx);
-			return -2;
-        }
-        else
-        {
-            // 2. 将packet发送给解码器
-            //    发送packet的顺序是按dts递增的顺序,如IPBBPBB
-            //    pkt.pos变量可以标识当前packet在视频文件中的地址偏移
-			int iresult = avcodec_send_packet(p_codec_ctx, &pkt);
-            if (AVERROR(EAGAIN) == iresult)
-            {
-				hostapi->Debug(MEDIA_LOG_DEBUG, "receive_frame and send_packet both returned EAGAIN, which is an API violation.");
-            }
-			if (0 == iresult)
-			{
-				av_packet_unref(&pkt);
-			}
-        }
-    }
-
-	return ret;
-}
-
-// 音频解码线程:从音频packet_queue中取数据,解码后放入音频frame_queue
-static int audio_decode_thread(void *arg)
-{
-    player_stat_t *is = (player_stat_t *)arg;
-    AVFrame *p_frame = av_frame_alloc();
-    frame_t *af;
-
-    int got_frame = 0;
-    AVRational tb;
-    int ret = 0;
-
-    if (p_frame == NULL){
-        return AVERROR(ENOMEM);
-    }
-
-	while (false == is->buser_stop)
-    {
-        got_frame = audio_decode_frame(is->p_acodec_ctx[is->iaudio_dec_index], &is->audio_pkt_queue, p_frame, is->rvc_hostapi);
-        if (got_frame < 0){
-			if(-2 == got_frame){
-				if (is->icurrent_index > is->iaudio_dec_index) {
-					is->iaudio_dec_index++;
-				}
-				continue;
-			}
-			else {
-				is->rvc_hostapi->Debug(MEDIA_LOG_DEBUG, " audio_decode_frame < 0, goto end");
-				goto the_end;
-			}
-		}
-
-        if (got_frame)
-        {
-            tb = { 1, p_frame->sample_rate };
-
-			//从frame队列找到一个可写的空间,若未停止则一直等待,已停止时返回NULL
-			if (!(af = frame_queue_peek_writable(&is->audio_frm_queue))) {
-				is->rvc_hostapi->Debug(MEDIA_LOG_DEBUG, "frame_queue_peek_writable return NULL, goto end.");
-				goto the_end;
-			}
-            af->pts = (p_frame->pts == AV_NOPTS_VALUE) ? NAN : p_frame->pts * av_q2d(tb);
-            af->pos = p_frame->pkt_pos;
-            //-af->serial = is->auddec.pkt_serial;
-            // 当前帧包含的(单个声道)采样数/采样率就是当前帧的播放时长
-			AVRational tbdata{ p_frame->nb_samples, p_frame->sample_rate };
-            //af->duration = av_q2d((AVRational) { p_frame->nb_samples, p_frame->sample_rate });
-			af->duration = av_q2d(tbdata);
-            // 将frame数据拷入af->frame,af->frame指向音频frame队列尾部
-            av_frame_move_ref(af->frame, p_frame);
-            // 更新音频frame队列大小及写指针
-            frame_queue_push(&is->audio_frm_queue);
-        }
-		av_usleep(RVC_DEFAULT_SLEEP_TIME);
-    }
-
-the_end:
-    av_frame_free(&p_frame);
-	is->rvc_hostapi->Debug(MEDIA_LOG_DEBUG, "audio decode thread exit, thread id is %u, and user stop flag is %s.", SDL_ThreadID(), is->buser_stop ? "true":"false");
-	is->baudio_decode_finished = true;
-
-	return ret;
-}
-
-int open_audio_stream(player_stat_t *is)
-{
-    AVCodecContext *p_codec_ctx = NULL;
-    AVCodecParameters *p_codec_par = NULL;
-    AVCodec* p_codec = NULL;
-    int ret = -1;
-
-    // 1. 为音频流构建解码器AVCodecContext
-	for (size_t index = 0; index < is->uFilesCount; index++){
-		// 1.1 获取解码器参数AVCodecParameters
-
-		p_codec_par = is->p_audio_stream[index]->codecpar;
-		// 1.2 获取解码器
-		p_codec = avcodec_find_decoder(p_codec_par->codec_id);
-		if (NULL == p_codec) {
-			is->rvc_hostapi->Debug(MEDIA_LOG_ERROR, "Cann't find codec!");
-			return ret;
-		}
-
-		// 1.3 构建解码器AVCodecContext
-		// 1.3.1 p_codec_ctx初始化:分配结构体,使用p_codec初始化相应成员为默认值
-		p_codec_ctx = avcodec_alloc_context3(p_codec);
-		if (p_codec_ctx == NULL) {
-			is->rvc_hostapi->Debug(MEDIA_LOG_ERROR, "avcodec_alloc_context3() failed.");
-			return ret;
-		}
-		// 1.3.2 p_codec_ctx初始化:p_codec_par ==> p_codec_ctx,初始化相应成员
-		ret = avcodec_parameters_to_context(p_codec_ctx, p_codec_par);
-		if (ret < 0) {
-			is->rvc_hostapi->Debug(MEDIA_LOG_ERROR, "avcodec_parameters_to_context() failed %d.", ret);
-			return ret;
-		}
-		// 1.3.3 p_codec_ctx初始化:使用p_codec初始化p_codec_ctx,初始化完成
-		ret = avcodec_open2(p_codec_ctx, p_codec, NULL);
-		if (ret < 0) {
-			is->rvc_hostapi->Debug(MEDIA_LOG_ERROR, "avcodec_open2() failed %d.", ret);
-			return ret;
-		}
-
-		p_codec_ctx->pkt_timebase = is->p_audio_stream[index]->time_base;
-		is->p_acodec_ctx[index] = p_codec_ctx;
-		is->rvc_hostapi->Debug(MEDIA_LOG_DEBUG, "%s:%d is->p_acodec_ctx[%d] = 0x%08x", __FUNCTION__, __LINE__, index, p_codec_ctx);
-	}
-
-    // 2. 创建音频解码线程
-	is->audio_decode_tid = SDL_CreateThread(audio_decode_thread, "audio decode thread", is);
-	if (NULL == is->audio_decode_tid) {
-		is->rvc_hostapi->Debug(MEDIA_LOG_ERROR, "SDL_Create audio decode thread failed: %s.", SDL_GetError());
-		return -1;
-	}
-	else {
-		ret = 0;
-		is->rvc_hostapi->Debug(MEDIA_LOG_DEBUG, "create %s success, and thread id is %u.", SDL_GetThreadName(is->audio_decode_tid), SDL_GetThreadID(is->audio_decode_tid));
-	}
-
-    return ret;
-}
-
-static int audio_resample(player_stat_t *is, int64_t audio_callback_time)
-{
-    int data_size = 0, resampled_data_size = 0;
-    int64_t dec_channel_layout = 0;
-    av_unused double audio_clock0 = 0.0;
-    int wanted_nb_samples = 0;
-    frame_t *af = NULL;
-
-    while (frame_queue_nb_remaining(&is->audio_frm_queue) == 0)
-    {
-		if ((av_gettime_relative() - audio_callback_time) > 1000000LL * is->audio_hw_buf_size / is->audio_param_tgt.bytes_per_sec / 2) {
-			return -1;
-		}
-        av_usleep(1000);
-    }
-
-    // 若队列头部可读,则由af指向可读帧
-	if (!(af = frame_queue_peek_readable(&is->audio_frm_queue))) {
-		is->rvc_hostapi->Debug(MEDIA_LOG_DEBUG, "%s:%d user stop flag is %s, function return", __FUNCTION__, __LINE__, is->buser_stop ? "true" : "false");
-		return -1;
-	}
-    frame_queue_next(&is->audio_frm_queue);
-
-    // 根据frame中指定的音频参数获取缓冲区的大小
-    data_size = av_samples_get_buffer_size(NULL, af->frame->channels,    // 本行两参数:linesize,声道数
-        af->frame->nb_samples,											 // 本行一参数:本帧中包含的单个声道中的样本数
-        (AVSampleFormat)af->frame->format, 1);							 // 本行两参数:采样格式,不对齐
-
-// 获取声道布局
-    dec_channel_layout =
-        (af->frame->channel_layout && af->frame->channels == av_get_channel_layout_nb_channels(af->frame->channel_layout)) ?
-        af->frame->channel_layout : av_get_default_channel_layout(af->frame->channels);
-    wanted_nb_samples = af->frame->nb_samples;
-
-    // is->audio_param_tgt是SDL可接受的音频帧数,是audio_open()中取得的参数
-    // 在audio_open()函数中又有“is->audio_src = is->audio_param_tgt”
-    // 此处表示:如果frame中的音频参数 == is->audio_src == is->audio_param_tgt,那音频重采样的过程就免了(因此时is->swr_ctr是NULL)
-    //      否则使用frame(源)和is->audio_param_tgt(目标)中的音频参数来设置is->swr_ctx,并使用frame中的音频参数来赋值is->audio_src
-    if (af->frame->format != is->audio_param_src.fmt ||
-        dec_channel_layout != is->audio_param_src.channel_layout ||
-        af->frame->sample_rate != is->audio_param_src.freq)
-    {
-        swr_free(&is->audio_swr_ctx);
-        // 使用frame(源)和is->audio_param_tgt(目标)中的音频参数来设置is->audio_swr_ctx
-        is->audio_swr_ctx = swr_alloc_set_opts(NULL,
-            is->audio_param_tgt.channel_layout, (AVSampleFormat)is->audio_param_tgt.fmt, is->audio_param_tgt.freq,
-            dec_channel_layout, (AVSampleFormat)af->frame->format, af->frame->sample_rate,
-            0, NULL);
-        if (!is->audio_swr_ctx || swr_init(is->audio_swr_ctx) < 0)
-        {
-			is->rvc_hostapi->Debug(MEDIA_LOG_ERROR, "Cannot create sample rate converter for conversion of %d Hz %s %d channels to %d Hz %s %d channels!",
-				af->frame->sample_rate, av_get_sample_fmt_name((AVSampleFormat)af->frame->format), af->frame->channels,
-				is->audio_param_tgt.freq, av_get_sample_fmt_name((AVSampleFormat)is->audio_param_tgt.fmt), is->audio_param_tgt.channels);
-            swr_free(&is->audio_swr_ctx);
-            return -1;
-        }
-        // 使用frame中的参数更新is->audio_src,第一次更新后后面基本不用执行此if分支了,因为一个音频流中各frame通用参数一样
-        is->audio_param_src.channel_layout = dec_channel_layout;
-        is->audio_param_src.channels = af->frame->channels;
-        is->audio_param_src.freq = af->frame->sample_rate;
-        is->audio_param_src.fmt = (AVSampleFormat)af->frame->format;
-    }
-	
-    if (is->audio_swr_ctx)
-    {
-        // 重采样输入参数1:输入音频样本数是af->frame->nb_samples
-        // 重采样输入参数2:输入音频缓冲区
-        const uint8_t **in = (const uint8_t **)af->frame->extended_data;
-        // 重采样输出参数1:输出音频缓冲区尺寸
-        // 重采样输出参数2:输出音频缓冲区
-        uint8_t **out = &is->audio_frm_rwr;
-        // 重采样输出参数:输出音频样本数(多加了256个样本)
-        int out_count = (int64_t)wanted_nb_samples * is->audio_param_tgt.freq / af->frame->sample_rate + 256;
-        // 重采样输出参数:输出音频缓冲区尺寸(以字节为单位)
-        int out_size = av_samples_get_buffer_size(NULL, is->audio_param_tgt.channels, out_count, (AVSampleFormat)is->audio_param_tgt.fmt, 0);
-        int len2 = 0;
-        if (out_size < 0){
-			is->rvc_hostapi->Debug(MEDIA_LOG_ERROR, "av_samples_get_buffer_size() failed.");
-            return -1;
-        }
-        av_fast_malloc(&is->audio_frm_rwr, &is->audio_frm_rwr_size, out_size);
-		if (!is->audio_frm_rwr) {
-			return AVERROR(ENOMEM);
-		}
-        // 音频重采样:返回值是重采样后得到的音频数据中单个声道的样本数
-        len2 = swr_convert(is->audio_swr_ctx, out, out_count, in, af->frame->nb_samples);
-        if (len2 < 0){
-			is->rvc_hostapi->Debug(MEDIA_LOG_ERROR, "swr_convert() failed.");
-            return -1;
-        }
-
-        if (len2 == out_count){
-			is->rvc_hostapi->Debug(MEDIA_LOG_ERROR, "audio buffer is probably too small.");
-			if (swr_init(is->audio_swr_ctx) < 0)
-                swr_free(&is->audio_swr_ctx);
-        }
-        is->p_audio_frm = is->audio_frm_rwr;
-        // 重采样返回的一帧音频数据大小(以字节为单位)
-        resampled_data_size = len2 * is->audio_param_tgt.channels * av_get_bytes_per_sample((AVSampleFormat)is->audio_param_tgt.fmt);
-    }
-    else
-    {
-        // 未经重采样,则将指针指向frame中的音频数据
-        is->p_audio_frm = af->frame->data[0];
-        resampled_data_size = data_size;
-    }
-
-    audio_clock0 = is->audio_clock;
-    /* update the audio clock with the pts */
-    if (!isnan(af->pts)){
-        is->audio_clock = af->pts + (double)af->frame->nb_samples / af->frame->sample_rate;
-    }
-    else{
-        is->audio_clock = NAN;
-    }
-    is->audio_clock_serial = af->serial;
-#ifdef DEBUG
-    {
-        static double last_clock;
-        //printf("audio: delay=%0.3f clock=%0.3f clock0=%0.3f\n",
-        //    is->audio_clock - last_clock,
-        //    is->audio_clock, audio_clock0);
-		//is->rvc_log("audio: delay=%0.3f clock=%0.3f clock0=%0.3f\n",
-		//	is->audio_clock - last_clock,
-		//	is->audio_clock, audio_clock0);
-        last_clock = is->audio_clock;
-    }
-#endif
-    return resampled_data_size;
-}
-
-static int open_audio_playing(void *arg)
-{
-    player_stat_t *is = (player_stat_t *)arg;
-	SDL_AudioSpec wanted_spec = {0};
-	SDL_AudioSpec actual_spec = {0};
-
-    wanted_spec.freq = is->p_acodec_ctx[is->iaudio_dec_index]->sample_rate;   // 采样率
-    wanted_spec.format = AUDIO_S16SYS;                  // S表带符号,16是采样深度,SYS表采用系统字节序
-    wanted_spec.channels = is->p_acodec_ctx[is->iaudio_dec_index]->channels;  // 声音通道数
-    wanted_spec.silence = 0;                            // 静音值
-    // wanted_spec.samples = SDL_AUDIO_BUFFER_SIZE;     // SDL声音缓冲区尺寸,单位是单声道采样点尺寸x通道数
-    // SDL声音缓冲区尺寸,单位是单声道采样点尺寸x声道数
-    wanted_spec.samples = FFMAX(SDL_AUDIO_MIN_BUFFER_SIZE, 2 << av_log2(wanted_spec.freq / SDL_AUDIO_MAX_CALLBACKS_PER_SEC));
-	wanted_spec.callback = sdl_audio_callback;          // 回调函数,若为NULL,则应使用SDL_QueueAudio()机制
-    wanted_spec.userdata = is;                          // 提供给回调函数的参数
-	
-	if (NULL == is->straudiodev) {
-		int iaudioapeaker = SDL_GetNumAudioDevices(0);
-		is->rvc_hostapi->Debug(MEDIA_LOG_DEBUG, "audio output device number is %d.", iaudioapeaker);
-		int i = 0;
-		for (; i < iaudioapeaker; i++) {
-			is->rvc_hostapi->Debug(MEDIA_LOG_DEBUG, "device id %d audio device name is %s.", i, SDL_GetAudioDeviceName(i, 0));
-			if (is->paudiodev && strstr(SDL_GetAudioDeviceName(i, 0), is->paudiodev)) {
-				const char* strdevname = SDL_GetAudioDeviceName(i, 0);
-				is->straudiodev = av_strdup(strdevname);
-				is->rvc_hostapi->Debug(MEDIA_LOG_INFO, "%s matched audio device name is %s.", is->paudiodev, strdevname);
-				break;
-			}
-		}
-		if (i == iaudioapeaker) {
-			is->rvc_hostapi->Debug(MEDIA_LOG_ERROR, "matched audio device name (%s) failed!", is->straudiodev ? is->straudiodev : "null");
-		}
-
-		{
-			int inum = SDL_GetNumAudioDrivers();
-			int i = 0;
-			is->rvc_hostapi->Debug(MEDIA_LOG_DEBUG, "Audio Drivers number is %d.", inum);
-			for (; i < inum; i++) {
-				const char* drivername = SDL_GetAudioDriver(i);
-				is->rvc_hostapi->Debug(MEDIA_LOG_DEBUG, "[%d] Audio Drivers name is %s.", i, drivername);
-			}
-		}
-		is->rvc_hostapi->Debug(MEDIA_LOG_INFO, "current audio driver name is %s.", SDL_GetCurrentAudioDriver());
-	}
-
-	while (!(is->m_audio_dev = SDL_OpenAudioDevice(is->straudiodev, 0, &wanted_spec, &actual_spec, SDL_AUDIO_ALLOW_FREQUENCY_CHANGE | SDL_AUDIO_ALLOW_CHANNELS_CHANGE))){
-		is->rvc_hostapi->Debug(MEDIA_LOG_ERROR, "SDL_OpenAudio (%d channels, %d Hz): %s",wanted_spec.channels, wanted_spec.freq, SDL_GetError());
-		if (!wanted_spec.channels) {
-			if (!wanted_spec.freq) {
-				is->rvc_hostapi->Debug(MEDIA_LOG_ERROR,"No more combinations to try, audio open failed!");
-				return -1;
-			}
-		}
-	}
-
-	is->rvc_hostapi->Debug(MEDIA_LOG_INFO, "SDL_OpenAudioDevice success and audio_dev is %d.", is->m_audio_dev);
-    is->audio_param_tgt.fmt = AV_SAMPLE_FMT_S16;
-    is->audio_param_tgt.freq = actual_spec.freq;
-    is->audio_param_tgt.channel_layout = av_get_default_channel_layout(actual_spec.channels);
-    is->audio_param_tgt.channels = actual_spec.channels;
-    is->audio_param_tgt.frame_size = av_samples_get_buffer_size(NULL, actual_spec.channels, 1, (AVSampleFormat)is->audio_param_tgt.fmt, 1);
-    is->audio_param_tgt.bytes_per_sec = av_samples_get_buffer_size(NULL, actual_spec.channels, actual_spec.freq, (AVSampleFormat)is->audio_param_tgt.fmt, 1);
-	
-	is->rvc_hostapi->Debug(MEDIA_LOG_INFO, "audio param target (%d channels, %d Hz, channel_layout(%d), frame_size(%d), bytes_per_sec(%d)).", actual_spec.channels, actual_spec.freq, is->audio_param_tgt.channel_layout, is->audio_param_tgt.frame_size, is->audio_param_tgt.bytes_per_sec);
-
-	if (is->audio_param_tgt.bytes_per_sec <= 0 || is->audio_param_tgt.frame_size <= 0){
-		is->rvc_hostapi->Debug(MEDIA_LOG_ERROR, "av_samples_get_buffer_size failed.");
-		SDL_CloseAudioDevice(is->m_audio_dev);
-		return -1;
-    }
-    is->audio_param_src = is->audio_param_tgt;
-    is->audio_hw_buf_size = actual_spec.size;   // SDL音频缓冲区大小
-    is->audio_frm_size = 0;
-    is->audio_cp_index = 0;
-
-	SDL_PauseAudioDevice(is->m_audio_dev, 0);
-
-	SDL_LockMutex(is->audio_play_wait_mutex);
-	SDL_CondWait(is->audio_play_cond, is->audio_play_wait_mutex);
-	SDL_UnlockMutex(is->audio_play_wait_mutex);
-
-	is->rvc_hostapi->Debug(MEDIA_LOG_INFO, "----------%s:%d before SDL Close Audio Device.", __FUNCTION__, __LINE__);
-	SDL_CloseAudioDevice(is->m_audio_dev);
-	is->rvc_hostapi->Debug(MEDIA_LOG_INFO, "---------%s:%d after SDL Close Audio Device", __FUNCTION__, __LINE__);
-
-	return 0;
-}
-
-// 音频处理回调函数。读队列获取音频包,解码,播放
-// 此函数被SDL按需调用,此函数不在用户主线程中,因此数据需要保护
-// \param[in]  opaque 用户在注册回调函数时指定的参数
-// \param[out] stream 音频数据缓冲区地址,将解码后的音频数据填入此缓冲区
-// \param[out] len    音频数据缓冲区大小,单位字节
-// 回调函数返回后,stream指向的音频缓冲区将变为无效
-// 双声道采样点的顺序为LRLRLR
-static void sdl_audio_callback(void *opaque, uint8_t*stream, int len)
-{
-    player_stat_t *is = (player_stat_t *)opaque;
-    int audio_size = 0, len1 = 0;
-
-	if (is->buser_stop){
-		SDL_LockMutex(is->audio_play_wait_mutex);
-		SDL_CondSignal(is->audio_play_cond);
-		SDL_UnlockMutex(is->audio_play_wait_mutex);
-		return;
-	}
-
-    int64_t audio_callback_time = av_gettime_relative();
-    while (len > 0 && false == is->buser_stop) // 输入参数len等于is->audio_hw_buf_size,是audio_open()中申请到的SDL音频缓冲区大小
-    {
-        if (is->audio_cp_index >= (int)is->audio_frm_size){
-            // 1. 从音频frame队列中取出一个frame,转换为音频设备支持的格式,返回值是重采样音频帧的大小
-            audio_size = audio_resample(is, audio_callback_time);
-			if (audio_size < 0){
-				if (-1 == audio_size) {
-					if (is->baudio_decode_finished) {
-						is->rvc_hostapi->Debug(MEDIA_LOG_DEBUG, "audio_size is -1 sdl_audio_callback return, and set abort flag to true.");
-						is->on_audio_play_finished(is->user_data);
-						SDL_LockMutex(is->audio_play_wait_mutex);
-						SDL_CondSignal(is->audio_play_cond);
-						SDL_UnlockMutex(is->audio_play_wait_mutex);
-						return;
-					}
-				}
-                /* if error, just output silence */
-                is->p_audio_frm = NULL;
-                is->audio_frm_size = SDL_AUDIO_MIN_BUFFER_SIZE / is->audio_param_tgt.frame_size * is->audio_param_tgt.frame_size;
-            }
-            else{
-                is->audio_frm_size = audio_size;
-            }
-            is->audio_cp_index = 0;
-        }
-        // 引入is->audio_cp_index的作用:防止一帧音频数据大小超过SDL音频缓冲区大小,这样一帧数据需要经过多次拷贝
-        // 用is->audio_cp_index标识重采样帧中已拷入SDL音频缓冲区的数据位置索引,len1表示本次拷贝的数据量
-        len1 = is->audio_frm_size - is->audio_cp_index;
-        if (len1 > len){
-            len1 = len;
-        }
-        // 2. 将转换后的音频数据拷贝到音频缓冲区stream中,之后的播放就是音频设备驱动程序的工作了
-        if (is->p_audio_frm != NULL){
-			SDL_memset(stream, 0, len1);
-			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);
-			SDL_MixAudioFormat(stream, (uint8_t*)is->p_audio_frm + is->audio_cp_index, AUDIO_S16SYS, len1, ivolume);
-			if (is->prvc_cb && is->prvc_cb->cb_playing_audiodata) {
-				is->prvc_cb->cb_playing_audiodata(&(is->audio_param_tgt), (uint8_t*)is->p_audio_frm + is->audio_cp_index, len1, is->prvc_cb->user_data);
-			}
-        }
-        else{
-			SDL_memset(stream, 0, len1);
-        }
-
-        len -= len1;
-        stream += len1;
-        is->audio_cp_index += len1;
-    }
-    // is->audio_write_buf_size是本帧中尚未拷入SDL音频缓冲区的数据量
-    is->audio_write_buf_size = is->audio_frm_size - is->audio_cp_index;
-	//is->rvc_hostapi->Debug("audio_write_buf_size == %d.", is->audio_write_buf_size);
-    /* Let's assume the audio driver that is used by SDL has two periods. */
-    // 3. 更新时钟
-    if (!isnan(is->audio_clock))
-    {
-        // 更新音频时钟,更新时刻:每次往声卡缓冲区拷入数据后
-        // 前面audio_decode_frame中更新的is->audio_clock是以音频帧为单位,所以此处第二个参数要减去未拷贝数据量占用的时间
-        set_clock_at(&is->audio_clk,
-            is->audio_clock - (double)(2 * is->audio_hw_buf_size + is->audio_write_buf_size) / is->audio_param_tgt.bytes_per_sec,
-            is->audio_clock_serial,
-            audio_callback_time / 1000000.0);
-    }
-}
-
-int open_audio(player_stat_t *is)
-{
-	is->rvc_hostapi->Debug(MEDIA_LOG_DEBUG, "enter open_audio()");
-	if (-1 == is->audio_idx[is->icurrent_index]){
-		is->rvc_hostapi->Debug(MEDIA_LOG_DEBUG, "not find audio stream");
-	}
-	else {
-		open_audio_stream(is);
-		open_audio_playing(is);
-	}
-
-	is->rvc_hostapi->Debug(MEDIA_LOG_DEBUG, "exit open_audio()");
-
-    return 0;
-}

+ 0 - 200
Other/unix/libmediaplayer/demux.cpp

@@ -1,200 +0,0 @@
-#include "demux.h"
-#include "packet.h"
-
-#ifndef RVC_MAX_BUFFER_LEN
-#define RVC_MAX_BUFFER_LEN 1024
-#endif
-
-static int decode_interrupt_cb(void *ctx)
-{
-    player_stat_t *is = (player_stat_t*)ctx;
-    //return (int)(is->bvideo_finished && is->baudio_finished);
-	return (int)(is->buser_stop);
-}
-
-static int demux_init(player_stat_t *is)
-{
-	int ret = -1;
-	for (int index = 0; index < is->uFilesCount; index++)
-	{
-		AVFormatContext* p_fmt_ctx = NULL;
-		int err = -1;
-		int a_idx = -1;
-		int v_idx = -1;
-
-		p_fmt_ctx = avformat_alloc_context();
-		if (!p_fmt_ctx){
-			is->rvc_hostapi->Debug(MEDIA_LOG_ERROR, "Could not allocate context.");
-			ret = AVERROR(ENOMEM);
-			break;
-		}
-		// 中断回调机制。为底层I/O层提供一个处理接口,比如中止IO操作。
-		p_fmt_ctx->interrupt_callback.callback = decode_interrupt_cb;
-		p_fmt_ctx->interrupt_callback.opaque = is;
-		// 1. 构建AVFormatContext
-		// 1.1 打开视频文件:读取文件头,将文件格式信息存储在"fmt context"中
-		err = avformat_open_input(&p_fmt_ctx, is->strPlayLists[index], NULL, NULL);
-		if (err < 0){
-			char buffer[RVC_MAX_BUFFER_LEN] = { 0 };
-			av_strerror(err, buffer, RVC_MAX_BUFFER_LEN);
-			is->rvc_hostapi->Debug(MEDIA_LOG_ERROR, "avformat_open_input file %s failed %d(%s).", is->strPlayLists[index], err, buffer);
-			ret = -1;
-			break;
-		}
-		is->p_fmt_ctx[index] = p_fmt_ctx;
-		is->rvc_hostapi->Debug(MEDIA_LOG_DEBUG, "is->p_fmt_ctx[%d] = 0x%08x, p_fmt_ctx = 0x%08x", index, is->p_fmt_ctx[index], p_fmt_ctx);
-
-		// 1.2 搜索流信息:读取一段视频文件数据,尝试解码,将取到的流信息填入p_fmt_ctx->streams
-		//     ic->streams是一个指针数组,数组大小是pFormatCtx->nb_streams
-		err = avformat_find_stream_info(p_fmt_ctx, NULL);
-		if (err < 0){
-			char strbuffer[RVC_MAX_BUFFER_LEN] = { 0 };
-			av_strerror(err, strbuffer, RVC_MAX_BUFFER_LEN);
-			is->rvc_hostapi->Debug(MEDIA_LOG_ERROR, "%s avformat_find_stream_info() failed %d(%s).", is->strPlayLists[index], err, strbuffer);
-			ret = -1;
-			break;
-		}
-
-		// 2. 查找第一个音频流/视频流
-		for (int i = 0; i < (int)p_fmt_ctx->nb_streams; i++){
-			if ((p_fmt_ctx->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) && (a_idx == -1)){
-				a_idx = i;
-				is->rvc_hostapi->Debug(MEDIA_LOG_DEBUG, "%s Find a audio stream, index %d, media type is %s.", is->strPlayLists[index], a_idx, Media_Type_Table[is->eMType]);
-			}
-			if ((p_fmt_ctx->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) && (v_idx == -1)){
-				v_idx = i;
-				is->rvc_hostapi->Debug(MEDIA_LOG_DEBUG, "%s Find a video stream, index %d, media type is %s.", is->strPlayLists[index], v_idx, Media_Type_Table[is->eMType]);
-			}
-			if (a_idx != -1 && v_idx != -1){
-				break;
-			}
-		}
-
-		if ((a_idx == -1 && v_idx == -1) || (eVideo_Type == is->eMType && v_idx == -1)){
-			is->rvc_hostapi->Debug(MEDIA_LOG_ERROR, "Invalid file %s can not find any audio/video stream.", is->strPlayLists[index]);
-			ret = -1;
-			if (NULL != p_fmt_ctx){
-				avformat_close_input(&p_fmt_ctx);
-				is->p_fmt_ctx[index] = NULL;
-			}
-			break;
-		}
-
-		is->audio_idx[index] = a_idx;
-		is->video_idx[index] = v_idx;
-		is->p_audio_stream[index] = p_fmt_ctx->streams[a_idx];
-		is->p_video_stream[index] = p_fmt_ctx->streams[v_idx];
-		
-		ret = 0;
-	}
-
-    return ret;
-}
-
-int demux_deinit()
-{
-    return 0;
-}
-
-static int stream_has_enough_packets(AVStream *st, int stream_id, packet_queue_t *queue)
-{
-    return stream_id < 0 ||
-           queue->abort_flag ||
-           (st->disposition & AV_DISPOSITION_ATTACHED_PIC) ||
-           queue->nb_packets > MIN_FRAMES && (!queue->duration || av_q2d(st->time_base) * queue->duration > 1.0);
-}
-
-/* this thread gets the stream from the disk or the network */
-static int demux_thread(void *arg)
-{
-    player_stat_t *is = (player_stat_t *)arg;
-    //AVFormatContext *p_fmt_ctx = is->p_fmt_ctx;
-    int ret = 0;
-    AVPacket pkt1, *pkt = &pkt1;
-
-    SDL_mutex *wait_mutex = SDL_CreateMutex();
-
-	is->rvc_hostapi->Debug(MEDIA_LOG_DEBUG, "begin %s av_read_frame, nFilecount is %d. current index is %d.", is->strPlayLists[is->icurrent_index], is->uFilesCount, is->icurrent_index);
-    // 4. 解复用处理
-	while (false == is->buser_stop)
-    {
-        /* if the queue are full, no need to read more */
-        if (is->audio_pkt_queue.packet_queue_size + is->video_pkt_queue.packet_queue_size > MAX_QUEUE_SIZE ||
-            (stream_has_enough_packets(is->p_audio_stream[is->icurrent_index], is->audio_idx[is->icurrent_index], &is->audio_pkt_queue) &&
-             stream_has_enough_packets(is->p_video_stream[is->icurrent_index], is->video_idx[is->icurrent_index], &is->video_pkt_queue)))
-        {
-            /* wait 10 ms */
-            SDL_LockMutex(wait_mutex);
-            SDL_CondWaitTimeout(is->continue_read_thread, wait_mutex, 10);
-            SDL_UnlockMutex(wait_mutex);
-            continue;
-        }
-
-        // 4.1 从输入文件中读取一个packet
-        ret = av_read_frame(is->p_fmt_ctx[is->icurrent_index], pkt);
-        if (ret < 0)
-        {
-            if (AVERROR_EOF == ret)
-            {
-                // 输入文件已读完,则往packet队列中发送NULL packet,以冲洗(flush)解码器,否则解码器中缓存的帧取不出来
-                if (is->video_idx[is->icurrent_index] >= 0){
-                    packet_queue_put_nullpacket(&is->video_pkt_queue, is->video_idx[is->icurrent_index], is->rvc_hostapi);
-                }
-                if (is->audio_idx[is->icurrent_index] >= 0){
-                    packet_queue_put_nullpacket(&is->audio_pkt_queue, is->audio_idx[is->icurrent_index], is->rvc_hostapi);
-                }
-
-				if (is->icurrent_index + 1 < is->uFilesCount){
-					is->icurrent_index++;
-					ret = 0;
-					is->rvc_hostapi->Debug(MEDIA_LOG_DEBUG, "begin %s av_read_frame, nFilecount is %d. current is->index is %d.", is->strPlayLists[is->icurrent_index], is->uFilesCount, is->icurrent_index);
-				}
-				else {
-					is->rvc_hostapi->Debug(MEDIA_LOG_DEBUG, "av_read_frame ret is AVERROR_EOF.");
-					break;
-				}
-            }
-
-            SDL_LockMutex(wait_mutex);
-            SDL_CondWaitTimeout(is->continue_read_thread, wait_mutex, 10);
-            SDL_UnlockMutex(wait_mutex);
-            continue;
-        }
-        
-        // 4.3 根据当前packet类型(音频、视频、字幕),将其存入对应的packet队列
-        if (pkt->stream_index == is->audio_idx[is->icurrent_index]){
-            packet_queue_put(&is->audio_pkt_queue, pkt, is->rvc_hostapi);
-        }
-        else if (pkt->stream_index == is->video_idx[is->icurrent_index]){
-            packet_queue_put(&is->video_pkt_queue, pkt, is->rvc_hostapi);
-        }
-        else{
-            av_packet_unref(pkt);
-        }
-		av_usleep(RVC_DEFAULT_SLEEP_TIME);
-    }
-
-    SDL_DestroyMutex(wait_mutex);
-	is->rvc_hostapi->Debug(MEDIA_LOG_DEBUG, "%s exit, thread id is %u, buser_stop flag is %s.",SDL_GetThreadName(is->read_tid), SDL_ThreadID(), is->buser_stop ? "true" : "false");
-
-    return 0;
-}
-
-int open_demux(player_stat_t *is)
-{
-    if (demux_init(is) != 0){
-		is->rvc_hostapi->Debug(MEDIA_LOG_ERROR, "demux_init() failed.");
-        return -1;
-    }
-
-    is->read_tid = SDL_CreateThread(demux_thread, "demux_thread", is);
-    if (is->read_tid == NULL){
-		is->rvc_hostapi->Debug(MEDIA_LOG_ERROR, "SDL_CreateThread() failed: %s.", SDL_GetError());
-        return -1;
-    }
-	else {
-		is->rvc_hostapi->Debug(MEDIA_LOG_DEBUG, "create %s success, and thread id is %u.", SDL_GetThreadName(is->read_tid), SDL_GetThreadID(is->read_tid));
-	}
-
-    return 0;
-}

+ 0 - 84
Other/unix/libmediaplayer/idatastruct.h

@@ -1,84 +0,0 @@
-#pragma once
-
-#ifdef _WIN32
-#ifndef RVC_NO_VTABLE
-#define RVC_NO_VTABLE __declspec(novtable)
-#endif // !RVC_NO_VTABLE
-
-#else
-#ifndef RVC_NO_VTABLE
-#define RVC_NO_VTABLE 
-#endif // !RVC_NO_VTABLE
-#endif // RVC_OS_WIN
-
-
-#ifndef TIME_LEN
-#define TIME_LEN      9
-#endif // !TIME_LEN
-
-#ifndef MAX_FILECOUNT
-#define MAX_FILECOUNT 32
-#endif // !MAX_FILECOUNT
-
-#ifndef MAX_PATH
-#define MAX_PATH 260
-#endif // !MAX_PATH
-
-typedef struct audio_param_s {
-	int freq;
-	int channels;
-	int channel_layout;
-	int fmt;
-	int frame_size;
-	int bytes_per_sec;
-}audio_param_t;
-
-
-enum media_loglevel {
-	MEDIA_LOG_DEBUG,
-	MEDIA_LOG_INFO,
-	MEDIA_LOG_ERROR,
-	MEDIA_LOG_NO
-};
-
-enum PlayModeEnum
-{
-	UNKNOWN = -1,                               
-	SINGLE,                                      
-	LOCALAUDIO,                                 
-	LOCALVIDEO           					
-};
-
-struct CMediaPlayConfig
-{
-	char strVideoRunTime_S[TIME_LEN];			
-	char strVideoRunTime_E[TIME_LEN];			
-
-	bool bFullScreen;                           
-	bool bPrimMonitor;                          
-	bool bSimpleMode;                           
-	PlayModeEnum eMode;                         
-	int nWndX;                                  
-	int nWndY;                                  
-	int nWndWidth;                              
-	int nWndHeight;                             
-	int nFileCnt;		                        
-	int nPlayCnt;		                       
-	int nPlayInterval;		                    
-	char strNamePrefix[MAX_PATH];               
-	char strRootPath[MAX_PATH];		            
-	char strFileNames[MAX_FILECOUNT][MAX_PATH]; 
-
-	int nVolume;								
-};
-
-
-struct RVC_NO_VTABLE CMediaHostApi
-{
-	virtual int LoadPlayConfig(CMediaPlayConfig& config, int CfgInx = 0) = 0;
-	virtual void Debug(media_loglevel log_level, const char* fmt, ...) = 0;
-	virtual void MediaPlayFinished(int iMediaType) = 0;
-	virtual int GetMediaPlayerIcoPath(char* strPath, size_t uLen) = 0;
-	virtual int GetAudioOutDevName(char* strDev, size_t uLen) = 0;
-	virtual int PlayingAudioDataCallback(audio_param_t *param, const void* input, unsigned long uaudiolen) = 0;
-};

+ 0 - 581
Other/unix/libmediaplayer/libmediaplayer.cpp

@@ -1,581 +0,0 @@
-#include "libmediaplayer.h"
-#include "player.h"
-#include <unistd.h>
-
-class libmediaplayer_impl
-{
-private:
-	CMediaHostApi* m_pHostApi;
-	CMediaPlayer* m_Player;
-	CMediaPlayConfig m_stPlayConfig;
-	
-public:
-	bool m_bisplaying;
-
-public:
-	libmediaplayer_impl(CMediaHostApi* pHostApi);
-	~libmediaplayer_impl();
-
-	bool isStop();
-	void PlayMediaFinished();
-	int StartPlayVideo(const char* pVideoDir, const char* pNamePrefix = NULL, int nVideoCount = 1);
-	int GetLocalAudioPlayingParams(rvc_media_player_param_t* pParam, const char* pAudioNames);
-	int StartPlayLocalAudio(const char* pAudioNames);
-	int GetLocalVideoPlayingParams(rvc_media_player_param_t* pParam);
-	int StartPlayLocalVideo(int nCfgInx, int nWndX, int nWndY, int nWndWidth, int nWndHeight);
-	int StartPlayMedia(CMediaPlayConfig& config);
-	bool StopPlay();
-	void SetVolume(int nVolume);
-	void StartPlaySalesRecordVideo(int nWndX, int nWndY, int nWndWidth, int nWndHeight, const char* pVideoDir, const char* pNamePrefix = NULL, int nVideoCount = 1);
-	void StartPlayVideoNotice(int nWndX, int nWndY, int nWndWidth, int nWndHeight, const char* pFileName);
-	bool checkIsPlay();
-	bool checkIsStop();
-	CMediaHostApi* GetHostApi();
-	int PlayingAudioPcmCallback(audio_param_t* param, const void* input, unsigned long uaudiolen);
-	bool IsFileValid(const char* pVideoName);
-};
-
-
-bool IsFileExist(const char* pFilePath)
-{
-	bool bRet = false;
-	if (NULL != pFilePath) {
-		if (0 == access(pFilePath, 0)) {
-			bRet = true;
-		}
-	}
-	return bRet;
-}
-
-// 按分隔符分隔字符串
-void CStringSplit(char* str, char** result, const char* del)
-{
-	char* ptr = NULL;
-	char* p = strtok_r(str, del, &ptr);
-	while (p != NULL)
-	{
-		*result++ = p;
-		p = strtok_r(NULL, del, &ptr);
-	}
-}
-
-static void __cb_play_finished(void* user_data)
-{
-	libmediaplayer_impl* pthis = static_cast<libmediaplayer_impl*>(user_data);
-	if (NULL != pthis) {
-		pthis->PlayMediaFinished();
-		pthis->m_bisplaying = false;
-	}
-}
-
-
-static int __cb_playing_audio_data(audio_param_t* param, const void* input, unsigned long uaudiolen, void* user_data)
-{
-	int iret = -1;
-	libmediaplayer_impl* pthis = static_cast<libmediaplayer_impl*>(user_data);
-	if (NULL != pthis) {
-		iret = pthis->PlayingAudioPcmCallback(param, input, uaudiolen);
-	}
-
-	return iret;
-}
-
-
-libmediaplayer_impl::libmediaplayer_impl(CMediaHostApi* pHostApi)
-{
-	m_pHostApi = pHostApi;
-
-	m_Player = new CMediaPlayer(pHostApi);
-	if (NULL == m_Player) {
-		pHostApi->Debug(MEDIA_LOG_DEBUG, "new MediaPlayer failed!");
-	}
-	memset(&m_stPlayConfig, 0, sizeof(CMediaPlayConfig));
-	m_bisplaying = false;
-}
-
-libmediaplayer_impl::~libmediaplayer_impl()
-{
-	m_pHostApi = NULL;
-	delete m_Player;
-	m_Player = NULL;
-	m_bisplaying = false;
-}
-
-bool libmediaplayer_impl::isStop() 
-{
-	return !m_bisplaying; 
-}
-
-void libmediaplayer_impl::PlayMediaFinished()
-{
-	m_pHostApi->Debug(MEDIA_LOG_DEBUG, "PlayMediaFinished!");
-	m_pHostApi->MediaPlayFinished(m_Player->GetPlayingMediaType());
-}
-
-
-int libmediaplayer_impl::PlayingAudioPcmCallback(audio_param_t* param, const void* input, unsigned long uaudiolen)
-{
-	return m_pHostApi->PlayingAudioDataCallback(param, input, uaudiolen);
-}
-
-
-bool libmediaplayer_impl::IsFileValid(const char* pVideoName)
-{
-	bool bret= false;
-	int err = -1;
-
-	AVFormatContext* p_fmt_ctx = avformat_alloc_context();
-	if (!p_fmt_ctx){
-		return bret;
-	}
-	
-	// 1. 构建AVFormatContext
-	// 1.1 打开视频文件:读取文件头,将文件格式信息存储在"fmt context"中
-	err = avformat_open_input(&p_fmt_ctx, pVideoName, NULL, NULL);
-	if (0 == err){
-		err = avformat_find_stream_info(p_fmt_ctx, NULL);
-		if (err >= 0){
-			for (int i = 0; i < (int)p_fmt_ctx->nb_streams; i++){
-				if ((p_fmt_ctx->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) || AVMEDIA_TYPE_VIDEO == p_fmt_ctx->streams[i]->codecpar->codec_type){
-					bret = true;
-				}
-			}
-		}
-	}
-
-	avformat_close_input(&p_fmt_ctx);
-	avformat_free_context(p_fmt_ctx);
-
-	return bret;
-}
-
-
-int libmediaplayer_impl::StartPlayVideo(const char* pVideoDir, const char* pNamePrefix, int nVideoCount)
-{
-	int iRet = -1;
-	if (NULL == pVideoDir || NULL == pNamePrefix) {
-		return iRet;
-	}
-
-	play_media_callback_t cb = {0};
-	cb.cb_play_media_finished = &__cb_play_finished;
-	cb.user_data = this;
-
-	m_pHostApi->Debug(MEDIA_LOG_DEBUG, "audio root path is %s.", pVideoDir);
-	char strVideoName[MAX_PATH] = { 0 };
-	snprintf(strVideoName, MAX_PATH, "%s/%s", pVideoDir, pNamePrefix);
-	m_pHostApi->Debug(MEDIA_LOG_DEBUG, "video full path is %s.", strVideoName);
-	if (!IsFileExist(strVideoName)) {
-		return iRet;
-	}
-
-	rvc_media_player_param_t t_param = { 0 };
-	t_param.p_input_file = strVideoName;
-	t_param.cb = &cb;
-	t_param.eType = eVideo_Type;
-	t_param.eWindType = eVideoSize_Type;
-	t_param.idisplaycx = SDL_WINDOWPOS_UNDEFINED;
-	t_param.idisplaycy = SDL_WINDOWPOS_UNDEFINED;
-
-	memcpy(t_param.strPlayLists[0], strVideoName, strlen(strVideoName));
-	t_param.uFilesCount = 1;
-
-	if (0 == m_Player->InitParam(&t_param)) {
-		m_bisplaying = true;
-		iRet = m_Player->StartMediaPlay();
-	}
-
-	return iRet;
-}
-
-int libmediaplayer_impl::GetLocalAudioPlayingParams(rvc_media_player_param_t* pParam, const char* pAudioNames)
-{
-	int iRet = -1;
-	if (NULL == pParam || NULL == pAudioNames) {
-		return iRet;
-	}
-
-	pParam->eType = eAudio_Type;
-	pParam->eWindType = eVideoSize_Type;
-
-	// 切分音频文件名
-	size_t uLen = strlen(pAudioNames);
-	char* Tmp = new char[uLen + 1];
-	memset(Tmp, 0, uLen + 1);
-	memcpy(Tmp, pAudioNames, uLen);
-
-	char* Result[MAX_FILECOUNT] = { NULL };
-	CStringSplit(Tmp, Result, "|");
-	int FileCount = 0;
-	char** pStr = Result;
-	while (*pStr != NULL) {
-		++pStr;
-		++FileCount;
-	}
-	m_stPlayConfig.bPrimMonitor = true;
-	m_stPlayConfig.nFileCnt = FileCount;
-	m_pHostApi->Debug(MEDIA_LOG_DEBUG, "wmp pAudioNames = %s!", pAudioNames);
-	m_pHostApi->Debug(MEDIA_LOG_DEBUG, "wmp config.nFileCnt = %d!", FileCount);
-	size_t uValidCount = 0;
-	for (int i = 0; i < FileCount && i < MAX_FILECOUNT; i++) {
-		char strFileName[MAX_PATH] = { 0 };
-		snprintf(strFileName, MAX_PATH, "%s%s", m_stPlayConfig.strRootPath, Result[i]);
-		if (IsFileExist(strFileName)) {
-			memcpy(pParam->strPlayLists[i], strFileName, strlen(strFileName));
-			uValidCount++;
-		}
-		else {
-			m_pHostApi->Debug(MEDIA_LOG_DEBUG, "File %s is not exist.", strFileName);
-			continue;
-		}
-	}
-	delete[] Tmp;
-	Tmp = NULL;
-
-	pParam->uFilesCount = uValidCount;
-	m_pHostApi->Debug(MEDIA_LOG_DEBUG, "pParam uFilesCount = %d", pParam->uFilesCount);
-	if (uValidCount > 0) {
-		iRet = 0;
-	}
-
-	return iRet;
-}
-
-
-int libmediaplayer_impl::StartPlayLocalAudio(const char* pAudioNames)
-{
-	int iRet = -1;
-	m_pHostApi->Debug(MEDIA_LOG_DEBUG, "StartPlayLocalAudio %s.", pAudioNames);
-
-	m_stPlayConfig.eMode = LOCALAUDIO;
-	iRet = m_pHostApi->LoadPlayConfig(m_stPlayConfig);
-	m_stPlayConfig.eMode = LOCALAUDIO;
-	if (0 != iRet) {
-		m_pHostApi->Debug(MEDIA_LOG_ERROR, "Load WmpConfiguration failed while play local audio!");
-		return iRet;
-	}
-	else {
-		m_pHostApi->Debug(MEDIA_LOG_DEBUG, "Load WmpConfiguration succeeded while play local audio!");
-		m_pHostApi->Debug(MEDIA_LOG_DEBUG, "m_stPlayConfig.strRootPath: %s", m_stPlayConfig.strRootPath);
-	}
-
-	rvc_media_player_param_t t_param = { 0 };
-	if (0 != GetLocalAudioPlayingParams(&t_param, pAudioNames)) {
-		return iRet;
-	}
-
-	play_media_callback_t cb = { 0 };
-	cb.cb_play_media_finished = &__cb_play_finished;
-	cb.cb_playing_audiodata = &__cb_playing_audio_data;
-	cb.user_data = this;
-	t_param.cb = &cb;
-
-	if (0 == m_Player->InitParam(&t_param)) {
-		m_pHostApi->Debug(MEDIA_LOG_DEBUG, "Player Init success!");
-		m_bisplaying = true;
-		iRet = m_Player->StartMediaPlay();
-	}
-	else {
-		m_pHostApi->Debug(MEDIA_LOG_ERROR, "Player Init failed!");
-	}
-	return iRet;
-}
-
-
-int libmediaplayer_impl::GetLocalVideoPlayingParams(rvc_media_player_param_t* pParam)
-{
-	int iRet = -1;
-	if (NULL == pParam) {
-		return iRet;
-	}
-
-	pParam->eType = eVideo_Type;
-	pParam->eWindType = eFullScreen_Type;
-	size_t uValidCount = 0;
-	for (int i = 0; i < m_stPlayConfig.nFileCnt && i < MAX_FILECOUNT; i++) {
-		char strFileName[MAX_PATH] = { 0 };
-		snprintf(strFileName, MAX_PATH, "%s%s", m_stPlayConfig.strRootPath, m_stPlayConfig.strFileNames[i]);
-		if (IsFileExist(strFileName)) {
-			memcpy(pParam->strPlayLists[i], strFileName, strlen(strFileName));
-			uValidCount++;
-		}
-		else {
-			m_pHostApi->Debug(MEDIA_LOG_DEBUG, "File %s is not exist.", strFileName);
-			continue;
-		}
-	}
-	pParam->uFilesCount = uValidCount;
-	m_pHostApi->Debug(MEDIA_LOG_DEBUG, "pParam uFilesCount = %d", pParam->uFilesCount);
-	if (uValidCount > 0) {
-		iRet = 0;
-	}
-
-	return iRet;
-}
-
-
-int libmediaplayer_impl::StartPlayLocalVideo(int nCfgInx, int nWndX, int nWndY, int nWndWidth, int nWndHeight)
-{
-	int iRet = -1;
-	m_stPlayConfig.eMode = LOCALVIDEO;
-	m_pHostApi->Debug(MEDIA_LOG_DEBUG, "nCfgInx=%d, nWndX=%d, nWndY=%d, nWndWidth=%d, nWndHeight=%d!", nCfgInx, nWndX, nWndY, nWndWidth, nWndHeight);
-	iRet = m_pHostApi->LoadPlayConfig(m_stPlayConfig, nCfgInx);
-	m_stPlayConfig.eMode = LOCALVIDEO;
-	m_stPlayConfig.nWndX = nWndX;
-	m_stPlayConfig.nWndY = nWndY;
-	m_stPlayConfig.nWndWidth = nWndWidth;
-	m_stPlayConfig.nWndHeight = nWndHeight;
-	if (0 != iRet) {
-		m_pHostApi->Debug(MEDIA_LOG_DEBUG, "Load WmpConfiguration failed while play local video!");
-		return iRet;
-	}
-	else {
-		m_pHostApi->Debug(MEDIA_LOG_DEBUG, "Load WmpConfiguration succeeded while play local video!");
-		m_pHostApi->Debug(MEDIA_LOG_DEBUG, "m_stPlayConfig.strRootPath: %s,m_stPlayConfig.nFileCnt:%d", m_stPlayConfig.strRootPath, m_stPlayConfig.nFileCnt);
-	}
-
-	// 判断当前时间是否允许播放
-	struct tm* ptm = NULL;
-	time_t t = time(NULL);
-	ptm = localtime(&t);
-	char strNow[TIME_LEN] = { 0 };
-	sprintf(strNow, "%02d:%02d:%02d", ptm->tm_hour, ptm->tm_min, ptm->tm_sec);
-	if (strcmp(strNow, m_stPlayConfig.strVideoRunTime_S) < 0 || strcmp(strNow, m_stPlayConfig.strVideoRunTime_E) >= 0)
-	{
-		//m_pHostApi->Debug("Now is %s, video play start time is %s, video play stop time is %s, play video rejected!", strNow, m_stPlayConfig.strVideoRunTime_S, m_stPlayConfig.strVideoRunTime_E);
-		iRet = 0;
-		return iRet;
-	}
-
-	rvc_media_player_param_t t_param = { 0 };
-	if (0 != GetLocalVideoPlayingParams(&t_param)) {
-		return iRet;
-	}
-
-	t_param.idisplaycx = SDL_WINDOWPOS_UNDEFINED;
-	t_param.idisplaycy = SDL_WINDOWPOS_UNDEFINED;
-	t_param.bvicemonitor = true;
-
-	play_media_callback_t cb = { 0 };
-	cb.cb_play_media_finished = &__cb_play_finished;
-	cb.user_data = this;
-	t_param.cb = &cb;
-
-	if (0 == m_Player->InitParam(&t_param)) {
-		m_bisplaying = true;
-		iRet = m_Player->StartMediaPlay();
-	}
-	else {
-		m_pHostApi->Debug(MEDIA_LOG_DEBUG, "player init failed!");
-	}
-
-	return iRet;
-}
-
-
-int libmediaplayer_impl::StartPlayMedia(CMediaPlayConfig& config)
-{
-	int iRet = -1;
-	memcpy(&m_stPlayConfig, &config, sizeof(CMediaPlayConfig));
-	// 判断当前时间是否允许播放
-	struct tm* ptm = NULL;
-	time_t t = time(NULL);
-	ptm = localtime(&t);
-	char strNow[TIME_LEN] = { 0 };
-	snprintf(strNow, TIME_LEN, "%02d:%02d:%02d", ptm->tm_hour, ptm->tm_min, ptm->tm_sec);
-	if (strcmp(strNow, m_stPlayConfig.strVideoRunTime_S) < 0 || strcmp(strNow, m_stPlayConfig.strVideoRunTime_E) >= 0)
-	{
-		m_pHostApi->Debug(MEDIA_LOG_DEBUG, "Now is %s, video play start time is %s, video play stop time is %s, play video rejected!", strNow, m_stPlayConfig.strVideoRunTime_S, m_stPlayConfig.strVideoRunTime_E);
-		iRet = -2;
-		return iRet;
-	}
-
-	rvc_media_player_param_t t_param = { 0 };
-	//if (0 != GetLocalVideoPlayingParams(&t_param)) {
-	//	return iRet;
-	//}
-	t_param.eType = eVideo_Type;
-	t_param.eWindType = eFullScreen_Type;
-	t_param.bvicemonitor = true;
-
-	char strFileName[MAX_PATH] = { 0 };
-	snprintf(strFileName, MAX_PATH, "%s%s", m_stPlayConfig.strRootPath, m_stPlayConfig.strFileNames[0]);
-	if (IsFileExist(strFileName)) {
-		memcpy(t_param.strPlayLists[0], strFileName, strlen(strFileName));
-		t_param.uFilesCount = 1;
-	}
-	else {
-		m_pHostApi->Debug(MEDIA_LOG_DEBUG, "File %s is not exist.", strFileName);
-		t_param.uFilesCount = 0;
-		return iRet;
-	}
-
-	m_pHostApi->Debug(MEDIA_LOG_DEBUG, "pParam uFilesCount = %d", t_param.uFilesCount);
-
-	play_media_callback_t cb = { 0 };
-	cb.cb_play_media_finished = &__cb_play_finished;
-	cb.user_data = this;
-	t_param.cb = &cb;
-
-	m_Player->SetVolume(config.nVolume);
-	if (0 == m_Player->InitParam(&t_param)) {
-		m_bisplaying = true;
-		iRet = m_Player->StartMediaPlay();
-	}
-	else {
-		m_pHostApi->Debug(MEDIA_LOG_DEBUG, "Player Init failed!");
-	}
-	return iRet;
-}
-
-bool libmediaplayer_impl::StopPlay()
-{
-	if (m_Player->GetPlayingFlag())
-	{
-		m_Player->StopMediaPlay();
-	}
-
-	return true;
-}
-
-void libmediaplayer_impl::SetVolume(int nVolume)
-{
-	//if (m_Player->GetPlayingFlag())
-	{
-		m_Player->SetVolume(nVolume);
-	}
-}
-
-void libmediaplayer_impl::StartPlaySalesRecordVideo(int nWndX, int nWndY, int nWndWidth, int nWndHeight, const char* pVideoDir, const char* pNamePrefix, int nVideoCount)
-{
-
-}
-
-void libmediaplayer_impl::StartPlayVideoNotice(int nWndX, int nWndY, int nWndWidth, int nWndHeight, const char* pFileName)
-{
-	int iRet = -1;
-	if (NULL == pFileName) {
-		return;
-	}
-
-	rvc_media_player_param_t t_param = { 0 };
-	t_param.uFilesCount = 1;
-	t_param.eType = eVideo_Type;
-	t_param.eWindType = eSpecified_Type;
-	t_param.idisplaycx = nWndX;
-	t_param.idisplaycy = nWndY;
-	t_param.idisplaywidth = nWndWidth;
-	t_param.idisplayheight = nWndHeight;
-	t_param.bvicemonitor = false;
-	memcpy(&t_param.strPlayLists[0], pFileName, strlen(pFileName));
-
-	play_media_callback_t cb = { 0 };
-	cb.cb_play_media_finished = &__cb_play_finished;
-	cb.user_data = this;
-	t_param.cb = &cb;
-
-	if (0 == m_Player->InitParam(&t_param)) {
-		m_bisplaying = true;
-		iRet = m_Player->StartMediaPlay();
-	}
-	else {
-		m_pHostApi->Debug(MEDIA_LOG_DEBUG, "player init failed!");
-	}
-
-	return;
-}
-
-
-bool libmediaplayer_impl::checkIsPlay()
-{
-	return m_bisplaying;
-}
-
-bool libmediaplayer_impl::checkIsStop()
-{
-	return !m_bisplaying;
-}
-
-CMediaHostApi* libmediaplayer_impl::GetHostApi() 
-{ 
-	return m_pHostApi; 
-}
-
-Clibmediaplayer::Clibmediaplayer(CMediaHostApi* pHostApi)
-{
-	m_pImpl = new libmediaplayer_impl(pHostApi);
-	return;
-}
-
-Clibmediaplayer::~Clibmediaplayer()
-{
-	delete m_pImpl;
-	m_pImpl = NULL;
-}
-
-int Clibmediaplayer::PlayVideo(const char* pVideoDir, const char* pNamePrefix, int nVideoCount)
-{
-	return m_pImpl->StartPlayVideo(pVideoDir, pNamePrefix, nVideoCount);
-}
-
-int Clibmediaplayer::PlayLocalAudio(const char* pAudioNames)
-{
-	m_pImpl->GetHostApi()->Debug(MEDIA_LOG_DEBUG, "Clibmediaplayer StartPlayLocalAudio");
-	return m_pImpl->StartPlayLocalAudio(pAudioNames);
-}
-
-int Clibmediaplayer::PlayLocalVideo(int nCfgInx, int nWndX, int nWndY, int nWndWidth, int nWndHeight)
-{
-	return m_pImpl->StartPlayLocalVideo(nCfgInx, nWndX, nWndY, nWndWidth, nWndHeight);
-}
-
-bool Clibmediaplayer::checkIsPlay()
-{
-	return m_pImpl->checkIsPlay();
-}
-
-bool Clibmediaplayer::checkIsStop()
-{
-	return m_pImpl->isStop();
-}
-
-int Clibmediaplayer::PlayMedia(CMediaPlayConfig& config)
-{
-	return m_pImpl->StartPlayMedia(config);
-}
-
-void Clibmediaplayer::Close()
-{
-	m_pImpl->StopPlay();
-}
-
-void Clibmediaplayer::SetVolume(int nVolume)
-{
-	m_pImpl->SetVolume(nVolume);
-}
-
-void Clibmediaplayer::PlaySalesRecordVideo(int nWndX, int nWndY, int nWndWidth, int nWndHeight, const char* pVideoDir, const char* pNamePrefix, int nVideoCount)
-{
-	m_pImpl->StartPlaySalesRecordVideo(nWndX, nWndY, nWndWidth, nWndHeight, pVideoDir, pNamePrefix, nVideoCount);
-}
-
-void Clibmediaplayer::PlayVideoNotice(int nWndX, int nWndY, int nWndWidth, int nWndHeight, const char* pFileName)
-{
-	m_pImpl->StartPlayVideoNotice(nWndX, nWndY, nWndWidth, nWndHeight, pFileName);
-}
-
-
-bool Clibmediaplayer::IsFileValid(const char* pVideoName)
-{
-	return m_pImpl->IsFileValid(pVideoName);
-}
-
-int mediaplayer_init()
-{
-	return 0;
-}
-
-int mediaplayer_term()
-{
-	return 0;
-}

+ 0 - 54
Other/unix/libmediaplayer/libmediaplayer.h

@@ -1,54 +0,0 @@
-#pragma once
-#include <stdio.h>
-
-#include "idatastruct.h"
-
-#ifdef _WIN32
-#ifdef LIBMEDIAPLAYER_EXPORTS
-#define LIBMEDIAPLAYER_API __declspec(dllexport)
-#else
-#define LIBMEDIAPLAYER_API __declspec(dllimport)
-#endif
-# elif ( defined(__GNUC__) &&  __GNUC__ >= 4 )
-#define LIBMEDIAPLAYER_API __attribute__((visibility("default")))
-#else // RVC_OS_WIN
-#define LIBMEDIAPLAYER_API
-#endif // RVC_OS_WIN
-
-class libmediaplayer_impl;
-
-class LIBMEDIAPLAYER_API Clibmediaplayer
-{
-public:
-	Clibmediaplayer(CMediaHostApi* pHostApi);
-
-	~Clibmediaplayer();
-
-	int PlayVideo(const char* pVideoDir, const char* pNamePrefix = NULL, int nVideoCount = 1);
-
-	int PlayLocalAudio(const char* pAudioNames);
-
-	int PlayLocalVideo(int nCfgInx, int nWndX, int nWndY, int nWndWidth, int nWndHeight);
-
-	void Close();
-
-	bool checkIsPlay();
-
-	bool checkIsStop();
-
-	int PlayMedia(CMediaPlayConfig& config);
-
-	void SetVolume(int nVolume);
-
-	void PlaySalesRecordVideo(int nWndX, int nWndY, int nWndWidth, int nWndHeight, const char* pVideoDir, const char* pNamePrefix = NULL, int nVideoCount = 1);
-
-	void PlayVideoNotice(int nWndX, int nWndY, int nWndWidth, int nWndHeight, const char* pVideoName);
-
-	bool IsFileValid(const char* pVideoName);
-
-private:
-	libmediaplayer_impl* m_pImpl;
-};
-
-extern "C" LIBMEDIAPLAYER_API int mediaplayer_init();
-extern "C" LIBMEDIAPLAYER_API int mediaplayer_term();

+ 0 - 11
Other/unix/libmediaplayer/packet.h

@@ -1,11 +0,0 @@
-#pragma once
-
-#include "player.h"
-
-int packet_queue_init(packet_queue_t *q, CMediaHostApi* m_hostapi);
-int packet_queue_put(packet_queue_t *q, AVPacket *pkt, CMediaHostApi* m_hostapi);
-int packet_queue_get(packet_queue_t *q, AVPacket *pkt, int block);
-int packet_queue_put_nullpacket(packet_queue_t *q, int stream_index, CMediaHostApi* hostapi);
-void packet_queue_destroy(packet_queue_t *q, CMediaHostApi* m_hostapi);
-void packet_queue_abort(packet_queue_t *q, CMediaHostApi* m_hostapi);
-

+ 0 - 288
Other/unix/libmediaplayer/player.h

@@ -1,288 +0,0 @@
-#pragma once
-
-#include <stdio.h>
-#include <stdint.h>
-#include <stdbool.h>
-#include "idatastruct.h"
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif // __cplusplus
-
-#include <libavcodec/avcodec.h>
-#include <libavformat/avformat.h>
-#include <libswscale/swscale.h>
-#include <libswresample/swresample.h>
-#include <libavutil/frame.h>
-#include <libavutil/time.h>
-#include <libavutil/imgutils.h>
-#include <libavutil/mem.h>
-
-#if defined(_WIN32)
-#include <SDL.h>
-#include <SDL_video.h>
-#include <SDL_render.h>
-#include <SDL_rect.h>
-#include <SDL_mutex.h>
-#else
-#include <SDL2/SDL.h>
-#include <SDL2/SDL_video.h>
-#include <SDL2/SDL_render.h>
-#include <SDL2/SDL_rect.h>
-#include <SDL2/SDL_mutex.h>
-#endif
-
-#ifdef __cplusplus
-}
-#endif // __cplusplus
-
-
-/* no AV sync correction is done if below the minimum AV sync threshold */
-#define AV_SYNC_THRESHOLD_MIN 0.04
-/* AV sync correction is done if above the maximum AV sync threshold */
-#define AV_SYNC_THRESHOLD_MAX 0.1
-/* If a frame duration is longer than this, it will not be duplicated to compensate AV sync */
-#define AV_SYNC_FRAMEDUP_THRESHOLD 0.1
-/* no AV correction is done if too big error */
-#define AV_NOSYNC_THRESHOLD 10.0
-
-/* polls for possible required screen refresh at least this often, should be less than 1/fps */
-#define REFRESH_RATE 0.01
-
-#define SDL_AUDIO_BUFFER_SIZE 1024
-#define MAX_AUDIO_FRAME_SIZE 192000
-
-#define MAX_QUEUE_SIZE (15 * 1024 * 1024)
-#define MIN_FRAMES 25
-
-/* Minimum SDL audio buffer size, in samples. */
-#define SDL_AUDIO_MIN_BUFFER_SIZE 512
-/* Calculate actual buffer size keeping in mind not cause too frequent audio callbacks */
-#define SDL_AUDIO_MAX_CALLBACKS_PER_SEC 30
-
-#define VIDEO_PICTURE_QUEUE_SIZE 3
-#define SUBPICTURE_QUEUE_SIZE 16
-#define SAMPLE_QUEUE_SIZE 9
-#define FRAME_QUEUE_SIZE FFMAX(SAMPLE_QUEUE_SIZE, FFMAX(VIDEO_PICTURE_QUEUE_SIZE, SUBPICTURE_QUEUE_SIZE))
-
-
-#define FF_QUIT_EVENT    (SDL_USEREVENT + 2)
-
-#ifndef RVC_MAX_DISPLAYNUM
-#define RVC_MAX_DISPLAYNUM 5
-#endif
-
-#ifndef RVC_DEFAULT_SLEEP_TIME
-#define RVC_DEFAULT_SLEEP_TIME 10*1000
-#endif
-
-typedef struct play_clock_s{
-    double pts;                     // 当前帧(待播放)显示时间戳,播放后,当前帧变成上一帧
-    double pts_drift;               // 当前帧显示时间戳与当前系统时钟时间的差值
-    double last_updated;            // 当前时钟(如视频时钟)最后一次更新时间,也可称当前时钟时间
-    double speed;                   // 时钟速度控制,用于控制播放速度
-    int serial;                     // 播放序列,所谓播放序列就是一段连续的播放动作,一个seek操作会启动一段新的播放序列
-    int paused;                     // 暂停标志
-    int *queue_serial;              // 指向packet_serial
-}play_clock_t;
-
-typedef struct sdl_video_s{
-    SDL_Window *window; 
-    SDL_Renderer *renderer;
-    SDL_Texture *texture;
-    SDL_Rect rect;
-}sdl_video_t;
-
-typedef struct packet_queue_s{
-    AVPacketList *first_pkt, *last_pkt;
-    int nb_packets;                 // 队列中packet的数量
-    int packet_queue_size;          // 队列所占内存空间大小
-    int64_t duration;               // 队列中所有packet总的播放时长
-    int abort_flag;
-    int serial;                     // 播放序列,所谓播放序列就是一段连续的播放动作,一个seek操作会启动一段新的播放序列
-    SDL_mutex *mutex;
-    SDL_cond * packet_cond;
-}packet_queue_t;
-
-/* Common struct for handling all types of decoded data and allocated render buffers. */
-typedef struct frame_s{
-    AVFrame *frame;
-    int serial;
-    double pts;           /* presentation timestamp for the frame */
-    double duration;      /* estimated duration of the frame */
-    int64_t pos;          // frame对应的packet在输入文件中的地址偏移
-    int width;
-    int height;
-    int format;
-    AVRational sar;
-    int uploaded;
-    int flip_v;
-}frame_t;
-
-typedef struct frame_queue_s{
-    frame_t queue[FRAME_QUEUE_SIZE];
-    int rindex;                     // 读索引。待播放时读取此帧进行播放,播放后此帧成为上一帧
-    int windex;                     // 写索引
-    int size;                       // 总帧数
-    int max_size;                   // 队列可存储最大帧数
-    int keep_last;
-    int rindex_shown;               // 当前是否有帧在显示
-    SDL_mutex *frame_mutex;
-    SDL_cond *frame_cond;
-    packet_queue_t *pktq;           // 指向对应的packet_queue
-}frame_queue_t;
-
-
-typedef struct play_media_callback_s {
-	void (*cb_play_media_finished)(void* user_data);
-	int (*cb_playing_audiodata)(audio_param_t* param, const void* input, unsigned long uaudiolen, void* user_data);
-	void* user_data;
-}play_media_callback_t;
-
-typedef enum eMediaType_s {
-	eAudio_Type,
-	eVideo_Type,
-	eImage_Type
-}eMediaType_t;
-
-static const char* Media_Type_Table[] = {
-	"Audio",
-	"Video",
-	"Image"
-};
-
-typedef enum eWindType_s {
-	eVideoSize_Type,
-	eFullScreen_Type,
-	eSpecified_Type
-}eWindType_t;
-
-typedef struct player_stat_s{
-    AVFormatContext *p_fmt_ctx[MAX_FILECOUNT];
-    AVStream *p_audio_stream[MAX_FILECOUNT];
-    AVStream *p_video_stream[MAX_FILECOUNT];
-    AVCodecContext *p_acodec_ctx[MAX_FILECOUNT];
-    AVCodecContext *p_vcodec_ctx[MAX_FILECOUNT];
-
-    int audio_idx[MAX_FILECOUNT];
-    int video_idx[MAX_FILECOUNT];
-
-    sdl_video_t sdl_video;
-
-    play_clock_t audio_clk;                   // 音频时钟
-    play_clock_t video_clk;                   // 视频时钟
-    double frame_timer;
-
-    packet_queue_t audio_pkt_queue;
-    packet_queue_t video_pkt_queue;
-
-    frame_queue_t audio_frm_queue;
-    frame_queue_t video_frm_queue;
-
-    struct SwsContext *img_convert_ctx[MAX_FILECOUNT];
-    struct SwrContext *audio_swr_ctx;
-    AVFrame *p_frm_yuv[MAX_FILECOUNT];
-	uint8_t *p_video_buffer[MAX_FILECOUNT];
-
-    audio_param_t audio_param_src;
-    audio_param_t audio_param_tgt;
-    int audio_hw_buf_size;              // SDL音频缓冲区大小(单位字节)
-    uint8_t *p_audio_frm;               // 指向待播放的一帧音频数据,指向的数据区将被拷入SDL音频缓冲区。若经过重采样则指向audio_frm_rwr,否则指向frame中的音频
-    uint8_t *audio_frm_rwr;             // 音频重采样的输出缓冲区
-    unsigned int audio_frm_size;        // 待播放的一帧音频数据(audio_buf指向)的大小
-    unsigned int audio_frm_rwr_size;    // 申请到的音频缓冲区audio_frm_rwr的实际尺寸
-    int audio_cp_index;                 // 当前音频帧中已拷入SDL音频缓冲区的位置索引(指向第一个待拷贝字节)
-    int audio_write_buf_size;           // 当前音频帧中尚未拷入SDL音频缓冲区的数据量,audio_frm_size = audio_cp_index + audio_write_buf_size
-    double audio_clock;
-    int audio_clock_serial;
-    
-    int paused;
-    int step;
-
-	volatile bool buser_stop;
-
-    SDL_cond *continue_read_thread;
-    SDL_Thread *read_tid;           // demux解复用线程
-	SDL_Thread* audio_decode_tid;	// 音频解码线程
-	volatile bool baudio_decode_finished;
-	SDL_Thread* video_decode_tid;   // 视频解码线程
-	volatile bool bvideo_decode_finished;
-	SDL_Thread* video_playing_tid;  // 视频播放线程
-	SDL_cond* audio_play_cond;
-	SDL_mutex* audio_play_wait_mutex;
-	
-	play_media_callback_t* prvc_cb;	// 播放状态回调函数
-	char* piconpath;				// icon图标路径
-	char* paudiodev;				// 音频输出设备名
-	eMediaType_t eMType;			// 媒体类型
-	eWindType_t eWindType;			// 视频框大小类型
-	volatile uint8_t uVolume;		// 音量大小1-128
-	char* straudiodev;				// 获取到的音频设备名
-	CMediaHostApi* rvc_hostapi;
-	SDL_AudioDeviceID m_audio_dev;
-	
-	char strPlayLists[MAX_FILECOUNT][MAX_PATH];		//播放列表,全路径
-	uint8_t uFilesCount;							//播放文件数
-	volatile int icurrent_index;					//当前播放文件索引
-	volatile int iaudio_dec_index;					//当前音频解码器索引
-	bool bCirclePlay;
-	bool bvice_monitor;
-	int iDisplayCx;
-	int iDisplayCy;
-	int iDisplayWidth;
-	int iDisplayHeight;
-	int (*on_audio_volume)(int* audiodata, void* user_data);
-	int (*on_audio_play_finished)(void* user_data);
-	void* user_data;
-}player_stat_t;
-
-
-typedef struct rvc_media_player_param_s{
-	char* p_input_file;
-	eMediaType_t eType;
-	eWindType_t eWindType;
-	int idisplaycx;
-	int idisplaycy;
-	int idisplaywidth;
-	int idisplayheight;
-	bool bvicemonitor;
-	char strPlayLists[MAX_FILECOUNT][MAX_PATH];		//播放列表,全路径
-	uint8_t uFilesCount;								//播放文件数
-	play_media_callback_t* cb;
-}rvc_media_player_param_t;
-
-
-double get_clock(play_clock_t *c);
-void set_clock_at(play_clock_t *c, double pts, int serial, double time);
-void set_clock(play_clock_t *c, double pts, int serial);
-
-class CMediaPlayer
-{
-public:
-	CMediaPlayer(CMediaHostApi* pHostApi);
-	~CMediaPlayer();
-
-	int InitParam(rvc_media_player_param_t* pMedia_Player);
-	int Initialize_Player_Stat(rvc_media_player_param_t* pMedia_Player);
-	int UnInitialize_Player_Stat();
-	int SetVolume(uint8_t uVolume);
-	bool GetPlayingFlag();
-	int StartMediaPlay();
-	int StopMediaPlay();
-	int ExitMediaPlayingThread();
-	int64_t GetMediaPlayingThreadId();
-	int GetViceVideoDisplayInfo(int* icx, int* icy, int* iwidth, int* iheight);
-	uint8_t GetVolume();
-	bool SetFinishedFlag();
-	eMediaType_t GetPlayingMediaType();
-
-private:
-	player_stat_t* m_player_stat;
-	bool m_bplaying;
-	uint8_t m_uvolume;
-	CMediaHostApi* m_hostapi;
-	char* m_piconpath;				// ico图标路径
-	char* m_paudiodev;				// 音频输出设备
-};
-

+ 0 - 606
Other/unix/libmediaplayer/video.cpp

@@ -1,606 +0,0 @@
-#include "video.h"
-#include "packet.h"
-#include "frame.h"
-#include "player.h"
-
-static int queue_picture(player_stat_t *is, AVFrame *src_frame, double pts, double duration, int64_t pos)
-{
-    frame_t *vp = NULL;
-
-	if (!(vp = frame_queue_peek_writable(&is->video_frm_queue))) {
-		return -1;
-	}
-
-    vp->sar = src_frame->sample_aspect_ratio;
-    vp->uploaded = 0;
-
-    vp->width = src_frame->width;
-    vp->height = src_frame->height;
-    vp->format = src_frame->format;
-
-    vp->pts = pts;
-    vp->duration = duration;
-    vp->pos = pos;
-    //vp->serial = serial;
-
-    //set_default_window_size(vp->width, vp->height, vp->sar);
-
-    // 将AVFrame拷入队列相应位置
-    av_frame_move_ref(vp->frame, src_frame);
-    // 更新队列计数及写索引
-    frame_queue_push(&is->video_frm_queue);
-
-    return 0;
-}
-
-
-// 从packet_queue中取一个packet,解码生成frame
-static int video_decode_frame(AVCodecContext *p_codec_ctx, packet_queue_t *p_pkt_queue, AVFrame *frame, CMediaHostApi* hostapi)
-{
-    int ret;
-    
-    while (0 == p_pkt_queue->abort_flag)
-    {
-		AVPacket pkt = {0};
-		av_init_packet(&pkt);
-        while (0 == p_pkt_queue->abort_flag)
-        {
-            // 3. 从解码器接收frame
-            // 3.1 一个视频packet含一个视频frame
-            //     解码器缓存一定数量的packet后,才有解码后的frame输出
-            //     frame输出顺序是按pts的顺序,如IBBPBBP
-            //     frame->pkt_pos变量是此frame对应的packet在视频文件中的偏移地址,值同pkt.pos
-			
-            ret = avcodec_receive_frame(p_codec_ctx, frame);
-            if (ret < 0)
-            {
-                if (ret == AVERROR_EOF)
-                {
-					hostapi->Debug(MEDIA_LOG_DEBUG, "video avcodec_receive_frame(): the decoder has been fully flushed.");
-					avcodec_flush_buffers(p_codec_ctx);
-                    return 0;
-                }
-                else if (ret == AVERROR(EAGAIN))
-                {
-					//hostapi->Debug(MEDIA_LOG_DEBUG,"video avcodec_receive_frame(): output is not available in this state - " "user must try to send new input");
-                    break;
-                }
-                else
-                {
-					hostapi->Debug(MEDIA_LOG_DEBUG, "video avcodec_receive_frame(): other errors.");
-					continue;
-                }
-            }
-            else
-            {
-                frame->pts = frame->best_effort_timestamp;
-                //frame->pts = frame->pkt_dts;
-                return 1;   // 成功解码得到一个视频帧,则返回
-            }
-        }
-
-        // 1. 取出一个packet。使用pkt对应的serial赋值给d->pkt_serial
-        if (packet_queue_get(p_pkt_queue, &pkt, true) < 0){
-            return -1;
-        }
-
-        if (pkt.data == NULL){
-            // 复位解码器内部状态/刷新内部缓冲区。
-            avcodec_flush_buffers(p_codec_ctx);
-        }
-        else{
-            // 2. 将packet发送给解码器
-            //    发送packet的顺序是按dts递增的顺序,如IPBBPBB
-            //    pkt.pos变量可以标识当前packet在视频文件中的地址偏移
-			int isend_ret = -1;
-			isend_ret = avcodec_send_packet(p_codec_ctx, &pkt);
-			
-			if (0 != isend_ret){
-				if (AVERROR(EAGAIN) == isend_ret) {
-					hostapi->Debug(MEDIA_LOG_DEBUG, "receive_frame and send_packet both returned EAGAIN, which is an API violation.");
-				}
-				else if (AVERROR_EOF == isend_ret) {
-					hostapi->Debug(MEDIA_LOG_DEBUG, "the decoder has been flushed, and no new packets can be sent to it");
-				}
-				else if (AVERROR(EINVAL) == isend_ret) {
-					hostapi->Debug(MEDIA_LOG_DEBUG, "codec not opened, it is an encoder, or requires flush");
-				}
-				else if (AVERROR(ENOMEM) == isend_ret) {
-					hostapi->Debug(MEDIA_LOG_DEBUG, "failed to add packet to internal queue, or similar");
-				}
-				else {
-					hostapi->Debug(MEDIA_LOG_DEBUG, "legitimate decoding errors and avcodec_send_packet result is %d.", isend_ret);
-				}
-			}
-            av_packet_unref(&pkt);
-        }
-    }
-}
-
-// 将视频包解码得到视频帧,然后写入picture队列
-static int video_decode_thread(void *arg)
-{
-    player_stat_t *is = (player_stat_t *)arg;
-    AVFrame *p_frame = av_frame_alloc();
-    double pts = 0.0;
-    double duration = 0.0;
-    int ret=0;
-    int got_picture = 0;
-
-    
-    if (p_frame == NULL){
-		is->rvc_hostapi->Debug(MEDIA_LOG_DEBUG, "av_frame_alloc() for p_frame failed.");
-		return AVERROR(ENOMEM);
-    }
-
-    while (false == is->buser_stop)
-    {
-		AVRational tb = is->p_video_stream[is->icurrent_index]->time_base;
-		AVRational frame_rate = av_guess_frame_rate(is->p_fmt_ctx[is->icurrent_index], is->p_video_stream[is->icurrent_index], NULL);
-        got_picture = video_decode_frame(is->p_vcodec_ctx[is->icurrent_index], &is->video_pkt_queue, p_frame, is->rvc_hostapi);
-        if (got_picture < 0){
-			//is->bvideo_finished = true;
-			is->rvc_hostapi->Debug(MEDIA_LOG_DEBUG, "video_decode_frame < 0, goto end and set video_finished flag to true.");
-            goto exit;
-        }
-
-		AVRational tbdata{ frame_rate.den, frame_rate.num };
-		duration = (frame_rate.num && frame_rate.den ? av_q2d(tbdata) : 0);   // 当前帧播放时长
-        //duration = (frame_rate.num && frame_rate.den ? av_q2d((AVRational){frame_rate.den, frame_rate.num}) : 0);   // 当前帧播放时长
-        pts = (p_frame->pts == AV_NOPTS_VALUE) ? NAN : p_frame->pts * av_q2d(tb);   // 当前帧显示时间戳
-        ret = queue_picture(is, p_frame, pts, duration, p_frame->pkt_pos);   // 将当前帧压入frame_queue
-        av_frame_unref(p_frame);
-
-        if (ret < 0){
-			is->rvc_hostapi->Debug(MEDIA_LOG_ERROR, "queue_picture return -1, goto end and set video_finished flag to true.");
-            goto exit;
-        }
-		//av_usleep(RVC_DEFAULT_SLEEP_TIME);
-    }
-
-exit:
-    av_frame_free(&p_frame);
-	is->rvc_hostapi->Debug(MEDIA_LOG_DEBUG, "video decode thread exit, thread id is %u, and user_stop flag is %s.", SDL_ThreadID(), is->buser_stop ? "true" : "false");
-	is->bvideo_decode_finished = true;
-
-    return 0;
-}
-
-// 根据视频时钟与同步时钟(如音频时钟)的差值,校正delay值,使视频时钟追赶或等待同步时钟
-// 输入参数delay是上一帧播放时长,即上一帧播放后应延时多长时间后再播放当前帧,通过调节此值来调节当前帧播放快慢
-// 返回值delay是将输入参数delay经校正后得到的值
-static double compute_target_delay(double delay, player_stat_t *is)
-{
-    double sync_threshold, diff = 0;
-
-    /* update delay to follow master synchronisation source */
-
-    /* if video is slave, we try to correct big delays by
-       duplicating or deleting a frame */
-    // 视频时钟与同步时钟(如音频时钟)的差异,时钟值是上一帧pts值(实为:上一帧pts + 上一帧至今流逝的时间差)
-    diff = get_clock(&is->video_clk) - get_clock(&is->audio_clk);
-    // delay是上一帧播放时长:当前帧(待播放的帧)播放时间与上一帧播放时间差理论值
-    // diff是视频时钟与同步时钟的差值
-
-    /* skip or repeat frame. We take into account the
-       delay to compute the threshold. I still don't know
-       if it is the best guess */
-    // 若delay < AV_SYNC_THRESHOLD_MIN,则同步域值为AV_SYNC_THRESHOLD_MIN
-    // 若delay > AV_SYNC_THRESHOLD_MAX,则同步域值为AV_SYNC_THRESHOLD_MAX
-    // 若AV_SYNC_THRESHOLD_MIN < delay < AV_SYNC_THRESHOLD_MAX,则同步域值为delay
-    sync_threshold = FFMAX(AV_SYNC_THRESHOLD_MIN, FFMIN(AV_SYNC_THRESHOLD_MAX, delay));
-    if (!isnan(diff))
-    {
-        if (diff <= -sync_threshold)        // 视频时钟落后于同步时钟,且超过同步域值
-            delay = FFMAX(0, delay + diff); // 当前帧播放时刻落后于同步时钟(delay+diff<0)则delay=0(视频追赶,立即播放),否则delay=delay+diff
-        else if (diff >= sync_threshold && delay > AV_SYNC_FRAMEDUP_THRESHOLD)  // 视频时钟超前于同步时钟,且超过同步域值,但上一帧播放时长超长
-            delay = delay + diff;           // 仅仅校正为delay=delay+diff,主要是AV_SYNC_FRAMEDUP_THRESHOLD参数的作用
-        else if (diff >= sync_threshold)    // 视频时钟超前于同步时钟,且超过同步域值
-            delay = 2 * delay;              // 视频播放要放慢脚步,delay扩大至2倍
-    }
-
-	//is->rvc_hostapi->Debug("video: delay=%0.3f A-V=%f", delay, -diff);
-    return delay;
-}
-
-static double vp_duration(player_stat_t *is, frame_t *vp, frame_t *nextvp) 
-{
-    if (vp->serial == nextvp->serial){
-        double duration = nextvp->pts - vp->pts;
-        if (isnan(duration) || duration <= 0)
-            return vp->duration;
-        else
-            return duration;
-    } 
-	else {
-        return 0.0;
-    }
-}
-
-static void update_video_pts(player_stat_t *is, double pts, int64_t pos, int serial) {
-    /* update current video pts */
-    set_clock(&is->video_clk, pts, serial);            // 更新vidclock
-    //-sync_clock_to_slave(&is->extclk, &is->vidclk);  // 将extclock同步到vidclock
-}
-
-static void video_display(player_stat_t *is)
-{
-    frame_t *vp = NULL;
-
-    vp = frame_queue_peek_last(&is->video_frm_queue);
-
-    // 图像转换:p_frm_raw->data ==> p_frm_yuv->data
-    // 将源图像中一片连续的区域经过处理后更新到目标图像对应区域,处理的图像区域必须逐行连续
-    // plane: 如YUV有Y、U、V三个plane,RGB有R、G、B三个plane
-    // slice: 图像中一片连续的行,必须是连续的,顺序由顶部到底部或由底部到顶部
-    // stride/pitch: 一行图像所占的字节数,Stride=BytesPerPixel*Width+Padding,注意对齐
-    // AVFrame.*data[]: 每个数组元素指向对应plane
-    // AVFrame.linesize[]: 每个数组元素表示对应plane中一行图像所占的字节数
-    sws_scale(is->img_convert_ctx[is->icurrent_index],                    // sws context
-              (const uint8_t *const *)vp->frame->data,			 // src slice
-              vp->frame->linesize,								 // src stride
-              0,												 // src slice y
-              is->p_vcodec_ctx[is->icurrent_index]->height,               // src slice height
-              is->p_frm_yuv[is->icurrent_index]->data,                    // dst planes
-              is->p_frm_yuv[is->icurrent_index]->linesize                 // dst strides
-             );
-    
-    // 使用新的YUV像素数据更新SDL_Rect
-    SDL_UpdateYUVTexture(is->sdl_video.texture,					   // sdl texture
-                         &is->sdl_video.rect,					   // sdl rect
-                         is->p_frm_yuv[is->icurrent_index]->data[0],        // y plane
-                         is->p_frm_yuv[is->icurrent_index]->linesize[0],    // y pitch
-                         is->p_frm_yuv[is->icurrent_index]->data[1],        // u plane
-                         is->p_frm_yuv[is->icurrent_index]->linesize[1],    // u pitch
-                         is->p_frm_yuv[is->icurrent_index]->data[2],        // v plane
-                         is->p_frm_yuv[is->icurrent_index]->linesize[2]     // v pitch
-                        );
-    
-    // 使用特定颜色清空当前渲染目标
-    SDL_RenderClear(is->sdl_video.renderer);
-    // 使用部分图像数据(texture)更新当前渲染目标
-    SDL_RenderCopy(is->sdl_video.renderer,              // sdl renderer
-                   is->sdl_video.texture,               // sdl texture
-                   NULL,                                // src rect, if NULL copy texture
-                   &is->sdl_video.rect                  // dst rect
-                  );
-    
-    // 执行渲染,更新屏幕显示
-    SDL_RenderPresent(is->sdl_video.renderer);
-}
-
-/* called to display each frame */
-static void video_refresh(void *opaque, double *remaining_time)
-{
-    player_stat_t *is = (player_stat_t *)opaque;
-    double time;
-    static bool first_frame = true;
-
-retry:
-    if (frame_queue_nb_remaining(&is->video_frm_queue) == 0)  // 所有帧已显示
-    {    
-        // nothing to do, no picture to display in the queue
-		//is->rvc_hostapi->Debug(MEDIA_LOG_DEBUG, "%s:%d, nothing to do, no picture to display in the queue.", __FUNCTION__, __LINE__);
-		av_usleep(100*1000);
-		return;
-    }
-
-    double last_duration, duration, delay;
-    frame_t *vp, *lastvp;
-    /* dequeue the picture */
-    lastvp = frame_queue_peek_last(&is->video_frm_queue);     // 上一帧:上次已显示的帧
-    vp = frame_queue_peek(&is->video_frm_queue);              // 当前帧:当前待显示的帧
-    // lastvp和vp不是同一播放序列(一个seek会开始一个新播放序列),将frame_timer更新为当前时间
-    if (first_frame)
-    {
-        is->frame_timer = av_gettime_relative() / 1000000.0;
-        first_frame = false;
-    }
-    // 暂停处理:不停播放上一帧图像
-    if (is->paused)
-        goto display;
-
-    /* compute nominal last_duration */
-    last_duration = vp_duration(is, lastvp, vp);        // 上一帧播放时长:vp->pts - lastvp->pts
-    delay = compute_target_delay(last_duration, is);    // 根据视频时钟和同步时钟的差值,计算delay值
-
-    time= av_gettime_relative()/1000000.0;
-    // 当前帧播放时刻(is->frame_timer+delay)大于当前时刻(time),表示播放时刻未到
-    if (time < is->frame_timer + delay) {
-        // 播放时刻未到,则更新刷新时间remaining_time为当前时刻到下一播放时刻的时间差
-        *remaining_time = FFMIN(is->frame_timer + delay - time, *remaining_time);
-        // 播放时刻未到,则不播放,直接返回
-        return;
-    }
-    // 更新frame_timer值
-    is->frame_timer += delay;
-    // 校正frame_timer值:若frame_timer落后于当前系统时间太久(超过最大同步域值),则更新为当前系统时间
-    if (delay > 0 && time - is->frame_timer > AV_SYNC_THRESHOLD_MAX)
-    {
-        is->frame_timer = time;
-    }
-
-    SDL_LockMutex(is->video_frm_queue.frame_mutex);
-    if (!isnan(vp->pts))
-    {
-        update_video_pts(is, vp->pts, vp->pos, vp->serial); // 更新视频时钟:时间戳、时钟时间
-    }
-    SDL_UnlockMutex(is->video_frm_queue.frame_mutex);
-
-    // 是否要丢弃未能及时播放的视频帧
-    if (frame_queue_nb_remaining(&is->video_frm_queue) > 1)  // 队列中未显示帧数>1(只有一帧则不考虑丢帧)
-    {         
-        frame_t *nextvp = frame_queue_peek_next(&is->video_frm_queue);  // 下一帧:下一待显示的帧
-        duration = vp_duration(is, vp, nextvp);             // 当前帧vp播放时长 = nextvp->pts - vp->pts
-        // 当前帧vp未能及时播放,即下一帧播放时刻(is->frame_timer+duration)小于当前系统时刻(time)
-        if (time > is->frame_timer + duration)
-        {
-            frame_queue_next(&is->video_frm_queue);   // 删除上一帧已显示帧,即删除lastvp,读指针加1(从lastvp更新到vp)
-            goto retry;
-        }
-    }
-
-    // 删除当前读指针元素,读指针+1。若未丢帧,读指针从lastvp更新到vp;若有丢帧,读指针从vp更新到nextvp
-    frame_queue_next(&is->video_frm_queue);
-
-display:
-    video_display(is);                      // 取出当前帧vp(若有丢帧是nextvp)进行播放
-}
-
-static int video_playing_thread(void *arg)
-{
-    player_stat_t *is = (player_stat_t *)arg;
-    double remaining_time = 0.0;
-
-    while ((false == is->buser_stop) && (false == is->bvideo_decode_finished)){
-        if (remaining_time > 0.0){
-            av_usleep((unsigned)(remaining_time * 1000000.0));
-        }
-        remaining_time = REFRESH_RATE;
-		//is->rvc_hostapi->Debug(MEDIA_LOG_DEBUG, "%s:%d.", __FUNCTION__, __LINE__);
-        // 立即显示当前帧,或延时remaining_time后再显示
-        video_refresh(is, &remaining_time);
-		//remaining_time += 0.020;
-		//is->rvc_hostapi->Debug(MEDIA_LOG_DEBUG, "%s:%d, remaining_time = %f.", __FUNCTION__, __LINE__, remaining_time);
-    }
-
-	is->rvc_hostapi->Debug(MEDIA_LOG_DEBUG, "video playing thread exit, thread id is %u, and user_stop flag is %s.", SDL_ThreadID(), is->buser_stop ? "true" : "false");
-   
-	return 0;
-}
-
-static uint32_t get_video_playing_wind_flag(eWindType_t eType)
-{
-	uint32_t uFlag = SDL_WINDOW_OPENGL|SDL_WINDOW_BORDERLESS|SDL_WINDOW_ALWAYS_ON_TOP|SDL_WINDOW_POPUP_MENU;
-
-	return uFlag;
-}
-
-static int open_video_playing(void* arg)
-{
-	player_stat_t* is = (player_stat_t*)arg;
-	int ret;
-	int buf_size;
-	uint8_t* buffer = NULL;
-	SDL_Surface* IconSurface = NULL;
-
-	for (size_t index = 0; index < is->uFilesCount; index++) {
-		is->p_frm_yuv[index] = av_frame_alloc();
-		if (is->p_frm_yuv[index] == NULL) {
-			is->rvc_hostapi->Debug(MEDIA_LOG_ERROR, "av_frame_alloc() for p_frm_raw failed");
-			return -1;
-		}
-
-		int iplay_video_width = is->p_vcodec_ctx[index]->width;
-		int iplay_video_height = is->p_vcodec_ctx[index]->height;
-		if (eFullScreen_Type == is->eWindType || eSpecified_Type == is->eWindType) {
-			iplay_video_width = is->iDisplayWidth;
-			iplay_video_height = is->iDisplayHeight;
-		}
-
-		// 为AVFrame.*data[]手工分配缓冲区,用于存储sws_scale()中目的帧视频数据
-		buf_size = av_image_get_buffer_size(AV_PIX_FMT_YUV420P,
-			iplay_video_width,
-			iplay_video_height,
-			1
-		);
-		// buffer将作为p_frm_yuv的视频数据缓冲区
-		buffer = (uint8_t*)av_malloc(buf_size);
-		if (buffer == NULL) {
-			is->rvc_hostapi->Debug(MEDIA_LOG_ERROR, "av_malloc() for buffer failed!");
-			return -1;
-		}
-		is->p_video_buffer[index] = buffer;
-		// 使用给定参数设定p_frm_yuv->data和p_frm_yuv->linesize
-		ret = av_image_fill_arrays(is->p_frm_yuv[index]->data,     // dst data[]
-			is->p_frm_yuv[index]->linesize,						   // dst linesize[]
-			is->p_video_buffer[index],							   // src buffer
-			AV_PIX_FMT_YUV420P,									   // pixel format
-			iplay_video_width,									   // width
-			iplay_video_height,									   // height
-			1													   // align
-		);
-
-		if (ret < 0) {
-			is->rvc_hostapi->Debug(MEDIA_LOG_ERROR, "av_image_fill_arrays() failed %d", ret);
-			return -1;;
-		}
-
-		// A2. 初始化SWS context,用于后续图像转换
-		//     此处第6个参数使用的是FFmpeg中的像素格式,对比参考注释B3
-		//     FFmpeg中的像素格式AV_PIX_FMT_YUV420P对应SDL中的像素格式SDL_PIXELFORMAT_IYUV
-		//     如果解码后得到图像的不被SDL支持,不进行图像转换的话,SDL是无法正常显示图像的
-		//     如果解码后得到图像的能被SDL支持,则不必进行图像转换
-		//     这里为了编码简便,统一转换为SDL支持的格式AV_PIX_FMT_YUV420P==>SDL_PIXELFORMAT_IYUV
-		is->img_convert_ctx[index] = sws_getContext(is->p_vcodec_ctx[index]->width,   // src width
-			is->p_vcodec_ctx[index]->height,  // src height
-			is->p_vcodec_ctx[index]->pix_fmt, // src format
-			iplay_video_width,			// dst width
-			iplay_video_height,			// dst height
-			AV_PIX_FMT_YUV420P,        // dst format
-			SWS_BICUBIC,               // flags
-			NULL,                      // src filter
-			NULL,                      // dst filter
-			NULL                       // param
-		);
-
-		if (is->img_convert_ctx[index] == NULL) {
-			is->rvc_hostapi->Debug(MEDIA_LOG_ERROR, "sws_getContext() failed.");
-			return -1;
-		}
-		else {
-			is->rvc_hostapi->Debug(MEDIA_LOG_DEBUG, "%s:%d is->img_convert_ctx[%d] = 0x%08x.", __FUNCTION__, __LINE__, index, is->img_convert_ctx[index]);
-		}
-
-		// SDL_Rect赋值
-		is->sdl_video.rect.x = 0;
-		is->sdl_video.rect.y = 0;
-		is->sdl_video.rect.w = iplay_video_width;
-		is->sdl_video.rect.h = iplay_video_height;
-
-		uint32_t uWindFlag = get_video_playing_wind_flag(is->eWindType);
-
-		is->rvc_hostapi->Debug(MEDIA_LOG_DEBUG, "%s:%d %d %d %d %d", __FUNCTION__, __LINE__, is->iDisplayCx,
-		is->iDisplayCy,
-		is->sdl_video.rect.w,
-		is->sdl_video.rect.h);
-
-		// 1. 创建SDL窗口,SDL 2.0支持多窗口
-		//    SDL_Window即运行程序后弹出的视频窗口,同SDL 1.x中的SDL_Surface
-		is->sdl_video.window = SDL_CreateWindow("rvc media player",
-			is->iDisplayCx,
-			is->iDisplayCy,
-			is->sdl_video.rect.w,
-			is->sdl_video.rect.h,
-			uWindFlag
-		);
-
-		if (is->sdl_video.window == NULL) {
-			is->rvc_hostapi->Debug(MEDIA_LOG_ERROR, "SDL_CreateWindow() failed: %s.", SDL_GetError());
-			return -1;
-		}
-		else {
-			is->rvc_hostapi->Debug(MEDIA_LOG_INFO, "SDL Create Window success.");
-		}
-
-		if (eFullScreen_Type == is->eWindType) {
-			SDL_SetWindowFullscreen(is->sdl_video.window, SDL_WINDOW_FULLSCREEN_DESKTOP);
-		}
-
-		int cx = 0, cy = 0;
-		SDL_GetWindowPosition(is->sdl_video.window, &cx, &cy);
-		is->rvc_hostapi->Debug(MEDIA_LOG_DEBUG, "window flag is 0x%08x, cx = %d, cy = %d.", SDL_GetWindowFlags(is->sdl_video.window), cx, cy);
-
-		if (NULL != is->piconpath) {
-			IconSurface = SDL_LoadBMP(is->piconpath);
-			if (NULL == IconSurface) {
-				is->rvc_hostapi->Debug(MEDIA_LOG_ERROR, "SDL_LoadBMP(%s) failed: %s", is->piconpath, SDL_GetError());
-			}
-			else {
-				SDL_SetWindowIcon(is->sdl_video.window, IconSurface);
-				SDL_FreeSurface(IconSurface);
-			}
-		}
-
-		// 2. 创建SDL_Renderer
-		//    SDL_Renderer:渲染器
-		is->sdl_video.renderer = SDL_CreateRenderer(is->sdl_video.window, -1, 0);
-		if (is->sdl_video.renderer == NULL)
-		{
-			is->rvc_hostapi->Debug(MEDIA_LOG_ERROR, "SDL_CreateRenderer() failed: %s", SDL_GetError());
-			return -1;
-		}
-
-		// 3. 创建SDL_Texture
-		//    一个SDL_Texture对应一帧YUV数据,同SDL 1.x中的SDL_Overlay
-		is->sdl_video.texture = SDL_CreateTexture(is->sdl_video.renderer,
-			SDL_PIXELFORMAT_IYUV,
-			SDL_TEXTUREACCESS_STREAMING,
-			is->sdl_video.rect.w,
-			is->sdl_video.rect.h
-		);
-
-		if (is->sdl_video.texture == NULL)
-		{
-			is->rvc_hostapi->Debug(MEDIA_LOG_ERROR, "SDL_CreateTexture() failed: %s", SDL_GetError());
-			return -1;
-		}
-
-		is->video_playing_tid = SDL_CreateThread(video_playing_thread, "video playing thread", is);
-		if (NULL == is->video_playing_tid) {
-			is->rvc_hostapi->Debug(MEDIA_LOG_ERROR, "SDL_Create video playing thread failed: %s.", SDL_GetError());
-			return -1;
-		}
-		else {
-			is->rvc_hostapi->Debug(MEDIA_LOG_DEBUG, "create %s success, and thread id is %u.", SDL_GetThreadName(is->video_playing_tid), SDL_GetThreadID(is->video_playing_tid));
-		}
-	}
-
-    return 0;
-}
-
-static int open_video_stream(player_stat_t *is)
-{
-    AVCodecParameters* p_codec_par = NULL;
-    AVCodec* p_codec = NULL;
-    AVCodecContext* p_codec_ctx = NULL;
-	int ret = -1;
-
-	for (size_t index = 0; index < is->uFilesCount; index++){
-		AVStream* p_stream = is->p_video_stream[index];
-
-		// 1. 为视频流构建解码器AVCodecContext
-		// 1.1 获取解码器参数AVCodecParameters
-		p_codec_par = p_stream->codecpar;
-
-		// 1.2 获取解码器
-		p_codec = avcodec_find_decoder(p_codec_par->codec_id);
-		if (p_codec == NULL) {
-			is->rvc_hostapi->Debug(MEDIA_LOG_ERROR, "Cann't find codec!");
-			return ret;
-		}
-
-		// 1.3 构建解码器AVCodecContext
-		// 1.3.1 p_codec_ctx初始化:分配结构体,使用p_codec初始化相应成员为默认值
-		p_codec_ctx = avcodec_alloc_context3(p_codec);
-		if (p_codec_ctx == NULL) {
-			is->rvc_hostapi->Debug(MEDIA_LOG_ERROR, "avcodec_alloc_context3() failed");
-			return ret;
-		}
-		// 1.3.2 p_codec_ctx初始化:p_codec_par ==> p_codec_ctx,初始化相应成员
-		ret = avcodec_parameters_to_context(p_codec_ctx, p_codec_par);
-		if (ret < 0) {
-			is->rvc_hostapi->Debug(MEDIA_LOG_ERROR, "avcodec_parameters_to_context() failed");
-			return ret;
-		}
-		// 1.3.3 p_codec_ctx初始化:使用p_codec初始化p_codec_ctx,初始化完成
-		ret = avcodec_open2(p_codec_ctx, p_codec, NULL);
-		if (ret < 0) {
-			is->rvc_hostapi->Debug(MEDIA_LOG_ERROR, "avcodec_open2() failed %d", ret);
-			return ret;
-		}
-		is->p_vcodec_ctx[index] = p_codec_ctx;
-	}
-
-    // 2. 创建视频解码线程
-	is->video_decode_tid = SDL_CreateThread(video_decode_thread, "video decode thread", is);
-	if (NULL == is->video_decode_tid) {
-		is->rvc_hostapi->Debug(MEDIA_LOG_ERROR, "SDL_Create video decode thread failed: %s.", SDL_GetError());
-		return -1;
-	}
-	else {
-		is->rvc_hostapi->Debug(MEDIA_LOG_DEBUG, "create %s success, and thread id is %u.", SDL_GetThreadName(is->video_decode_tid), SDL_GetThreadID(is->video_decode_tid));
-	}
-
-    return 0;
-}
-
-int open_video(player_stat_t *is)
-{
-	is->rvc_hostapi->Debug(MEDIA_LOG_DEBUG, "enter open_video()");
-    open_video_stream(is);
-    open_video_playing(is);
-	is->rvc_hostapi->Debug(MEDIA_LOG_DEBUG, "exit open_video()");
-
-    return 0;
-}

+ 0 - 55
Other/unix/libpictureplayer/CMakeLists.txt

@@ -1,55 +0,0 @@
-set(MODULE_NAME "pictureplayer")
-set(MODULE_PREFIX "LIB_PICTUREPLAYER_FUNC")
-
-
-set(${MODULE_PREFIX}_SRCS
-	CPicturePlayer.h
-	CPicturePlayer.cpp
-	libpictureplayer.h
-	libpictureplayer.cpp
-)
-
-add_library(${MODULE_NAME} SHARED ${${MODULE_PREFIX}_SRCS})
-
-
-target_include_directories(${MODULE_NAME} PRIVATE
-	${RVC_COMMON_INCLUDE_DIR}
-	${RVC_WINPR_INCLUDE_DIR}
-	${CONAN_INCLUDE_DIRS_SDL2}
-	${RVC_FRAMEWORK_INCLUDES_DIR}
-	)
-
-
-target_link_directories(${MODULE_NAME} PRIVATE
-	${CONAN_LIB_DIRS_SDL2}
-	)
-
-target_link_libraries(${MODULE_NAME} PRIVATE ${${MODULE_PREFIX}_LIBS}	PRIVATE
-	${CONAN_LIBS_SDL2}
-	)  
-
-
-target_compile_definitions(${MODULE_NAME} PUBLIC "LIBPICTUREPLAYER_EXPORTS")
-
-
-if(MSVC)
-	install(TARGETS ${MODULE_NAME} 
-    RUNTIME DESTINATION "${RVC_RUNTIME_PATH}" COMPONENT libraries
-    ARCHIVE DESTINATION "${RVC_LIBRARY_PATH}" COMPONENT develops EXCLUDE_FROM_ALL
-    LIBRARY DESTINATION "${RVC_LIBRARY_PATH}" COMPONENT libraries
-    )
-else()
-install(TARGETS ${MODULE_NAME} 
-    RUNTIME DESTINATION "${RVC_RUNTIME_PATH}"
-    ARCHIVE DESTINATION "${RVC_LIBRARY_PATH}"
-    LIBRARY DESTINATION "${RVC_RUNTIME_PATH}"
-    COMPONENT libraries)
-endif(MSVC)
-
-
-# ����Ҫ���������ĵ�������
-if(MSVC)
-set(OTHER_CONAN_DEP_LIBS ${OTHER_CONAN_DEP_LIBS} ${CONAN_BIN_DIRS} PARENT_SCOPE)
-else()
-set(OTHER_CONAN_DEP_LIBS ${OTHER_CONAN_DEP_LIBS} ${CONAN_LIB_DIRS} PARENT_SCOPE)
-ENDIF(MSVC)

+ 0 - 326
Other/unix/libpictureplayer/CPicturePlayer.cpp

@@ -1,326 +0,0 @@
-#include <stdio.h>
-#include <stdbool.h>
-#include <assert.h>
-#include <string.h>
-#include <time.h>
-#include <errno.h>
-
-#include "CPicturePlayer.h"
-
-static char* rvc_strdup(const char* strdata)
-{
-	char* strbuffer = NULL;
-	if (NULL == strdata)
-	{
-		return strbuffer;
-	}
-	
-	uint8_t ulen = strlen(strdata);
-	if (strbuffer = (char*)malloc(ulen + 1)) 
-	{
-		memset(strbuffer, 0, ulen + 1);
-		memcpy(strbuffer, strdata, ulen);
-	}
-
-	return strbuffer;
-}
-
-
-static void rvc_strfree(char* strdata)
-{
-	if (NULL != strdata)
-	{
-		free(strdata);
-		strdata = NULL;
-	}
-}
-
-
-CPicturePlayer::CPicturePlayer(CPicHostApi* pHostApi)
-{
-	m_thid = NULL;
-	m_bplaying = false;
-	
-	m_window = NULL;
-	m_nfile_cnt = 0;
-	m_nplay_cnt = 0;
-	m_nplay_interval = 5000;
-	m_stricopath = NULL;
-	memset(m_strroot_path, 0, MAX_PATH);
-	for (size_t i = 0; i < MAX_FILECOUNT; i++){
-		memset(m_strfile_names[i], 0, MAX_PATH);
-	}
-	m_pHostApi = pHostApi;
-	if (NULL != m_pHostApi){
-		char strIcoPath[MAX_PATH] = { 0 };
-		if (0 == pHostApi->GetPicPlayerIcoPath(strIcoPath, MAX_PATH)) {
-			m_stricopath = rvc_strdup(strIcoPath);
-		}
-	}
-	else
-	{
-		m_pHostApi->PicDebug(PIC_LOG_ERROR,"new CPicturePlayer failed!");
-	}
-
-	for (int inum = 0; inum < MAX_DISPLAYNUM; inum++){
-		memset(&m_dispalymode[inum], 0, sizeof(SDL_DisplayMode));
-	}
-	m_show_width = 0;
-	m_show_height = 0;
-	m_busrstop = false;
-
-	Uint32 uRet = SDL_WasInit(SDL_INIT_VIDEO);
-
-	if (0 == uRet) {
-		if (SDL_Init(SDL_INIT_VIDEO))
-		{
-			m_pHostApi->PicDebug(PIC_LOG_ERROR, "Could not initialize SDL - %s", SDL_GetError());
-			m_pHostApi->PicDebug(PIC_LOG_ERROR, "(Did you set the DISPLAY variable?)");
-		}
-		else {
-			uRet = SDL_WasInit(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_TIMER);
-			m_pHostApi->PicDebug(PIC_LOG_DEBUG, "initialize SDL success, and init ret = %d.", uRet);
-		}
-	}
-}
-
-CPicturePlayer::~CPicturePlayer()
-{
-	DeInit();
-}
-
-size_t CPicturePlayer::GetVideoDisplayInfo()
-{
-	size_t uCount = SDL_GetNumVideoDisplays();
-	m_pHostApi->PicDebug(PIC_LOG_DEBUG,"VideoDisplays Number is %d.", uCount);
-	for (size_t i = 0; i < uCount && i < MAX_DISPLAYNUM; i++){
-		SDL_GetDesktopDisplayMode(i, &m_dispalymode[i]);
-		m_pHostApi->PicDebug(PIC_LOG_DEBUG,"VideoDisplays{%d} format = %d", i, m_dispalymode[i].format);
-		m_pHostApi->PicDebug(PIC_LOG_DEBUG,"VideoDisplays{%d} w = %d", i, m_dispalymode[i].w);
-		m_pHostApi->PicDebug(PIC_LOG_DEBUG,"VideoDisplays{%d} h = %d", i, m_dispalymode[i].h);
-		m_pHostApi->PicDebug(PIC_LOG_DEBUG,"VideoDisplays{%d} refresh_rate = %d", i, m_dispalymode[i].refresh_rate);
-	}
-	return uCount;
-}
-
-int CPicturePlayer::InitParam(rvc_picture_player_param_t* tparam)
-{
-	int iRet = -1;
-	if (NULL == tparam) {
-		return iRet;
-	}
-
-	//if (0 != SDL_Init(SDL_INIT_VIDEO)) {
-	//	m_pHostApi->PicDebug(PIC_LOG_ERROR,"Could not initialize SDL - %s", SDL_GetError());
-	//	m_pHostApi->PicDebug(PIC_LOG_ERROR, "(Did you set the DISPLAY variable?)");
-	//	return iRet;
-	//}
-
-	sem_init(&m_play_exit_sem, 0, 0);
-	m_busrstop = false;
-
-	m_nfile_cnt = tparam->nfile_cnt;
-	m_nplay_cnt = tparam->nplay_cnt;
-	m_nplay_interval = tparam->nplay_interval;
-	snprintf(m_strroot_path, MAX_PATH, "%s", tparam->strroot_path);
-	for (size_t index = 0; index < m_nfile_cnt; index++) {
-		snprintf(m_strfile_names[index], MAX_PATH, "%s", tparam->strfile_names[index]);
-	}
-
-	Uint32 uflag = SDL_WINDOW_SHOWN|SDL_WINDOW_BORDERLESS|SDL_WINDOW_ALWAYS_ON_TOP|SDL_WINDOW_POPUP_MENU;
-	if (tparam->bfull_screen) {
-		uflag += SDL_WINDOW_FULLSCREEN;
-	}
-
-	size_t uVideoPlayNum = GetVideoDisplayInfo();
-
-	int idispalycx = 0;
-	int idispalycy = 0;
-	int idispaly_width = m_dispalymode[0].w;
-	int idispaly_height = m_dispalymode[0].h;
-
-	if (false == tparam->bprim_monitor && uVideoPlayNum > 1) {
-		idispalycx = m_dispalymode[0].w;
-		idispaly_width = m_dispalymode[1].w;
-		idispaly_height = m_dispalymode[1].h;
-	}
-
-	m_show_width = idispaly_width;
-	m_show_height = idispaly_height;
-
-	//1.创建播放窗体
-	m_window = SDL_CreateWindow("rvc picture player",
-		idispalycx,// 不关心窗口X坐标
-		idispalycy,// 不关心窗口Y坐标
-		idispaly_width,
-		idispaly_height,
-		uflag
-	);
-
-	if (NULL == m_window){
-		m_pHostApi->PicDebug(PIC_LOG_ERROR, "SDL_CreateWindow() failed: %s.", SDL_GetError());
-		return -1;
-	}
-	else{
-		int cx = 0, cy = 0;
-		SDL_GetWindowPosition(m_window, &cx, &cy);
-		m_pHostApi->PicDebug(PIC_LOG_DEBUG, "window flag is 0x%08x, cx = %d, cy = %d.", SDL_GetWindowFlags(m_window), cx, cy);
-	}
-
-	//2.设置播放器ico
-	if (NULL != m_stricopath) {
-		SDL_Surface* IconSurface = SDL_LoadBMP(m_stricopath);
-		if (NULL == IconSurface) {
-			m_pHostApi->PicDebug(PIC_LOG_ERROR, "SDL_LoadBMP(%s) failed: %s", m_stricopath, SDL_GetError());
-		}
-		else {
-			SDL_SetWindowIcon(m_window, IconSurface);
-			SDL_FreeSurface(IconSurface);
-		}
-	}
-
-	iRet = 0;
-	return iRet;
-}
-
-
-int CPicturePlayer::DeInit()
-{
-	int iRet = -1;
-	rvc_strfree(m_stricopath);
-	m_stricopath = NULL;
-	m_show_width = 0;
-	m_show_height = 0;
-	m_busrstop = false;
-	sem_destroy(&m_play_exit_sem);
-
-	if (NULL != m_window) {
-		SDL_DestroyWindow(m_window);
-	}
-
-	SDL_Quit();
-
-	iRet = 0;
-
-	return iRet;
-}
-
-
-bool CPicturePlayer::StartPicPlay()
-{
-	bool bRet = false;
-
-	m_bplaying = true;
-
-	m_pHostApi->PicDebug(PIC_LOG_DEBUG, "set m_bplaying = true");
-
-	SDL_Surface* surface = SDL_GetWindowSurface(m_window);
-
-	int iPlayCount = 0;
-	for (; iPlayCount < m_nplay_cnt; iPlayCount++)
-	{
-		if (m_busrstop) {
-			break;
-		}
-
-		int index = 0;
-		for (; index < m_nfile_cnt; index++)
-		{
-			if (m_busrstop) {
-				break;
-			}
-			
-			SDL_Surface* image = IMG_Load(m_strfile_names[index]);
-			if (NULL == image) {
-				m_pHostApi->PicDebug(PIC_LOG_ERROR, "IMG_Load %s failed!", m_strfile_names[index]);
-				image = SDL_LoadBMP(m_strfile_names[index]);
-				if (NULL == image) {
-					continue;
-				}
-			}
-			else {
-				m_pHostApi->PicDebug(PIC_LOG_DEBUG, "IMG_Load %s success!", m_strfile_names[index]);
-			}
-
-			SDL_Rect dst;
-			dst.x = 0;
-			dst.y = 0;
-			dst.w = m_show_width;
-			dst.h = m_show_height;
-
-			SDL_BlitSurface(image, NULL, surface, &dst);
-
-			SDL_UpdateWindowSurface(m_window);
-			SDL_FreeSurface(surface);
-			SDL_FreeSurface(image);
-			//SDL_Delay(m_nplay_interval);
-
-			struct timespec ts;
-			int itimems = m_nplay_interval;
-			m_pHostApi->PicDebug(PIC_LOG_DEBUG, "%s:%d itimems = %d.", __FUNCTION__, __LINE__, itimems);
-
-			clock_gettime(CLOCK_REALTIME, &ts);
-			if (itimems > 1000){
-				ts.tv_sec += (itimems / 1000);
-				itimems = m_nplay_interval % 1000;
-			}
-			
-			long unsec = ts.tv_nsec + (1000 * 1000 * itimems);
-			ts.tv_sec += (unsec / 1000000000);
-			ts.tv_nsec = (unsec % 1000000000);
-
-			if (-1 == sem_timedwait(&m_play_exit_sem, &ts)) {
-				if (ETIMEDOUT == errno) {
-
-				}
-			}
-			else {
-				m_pHostApi->PicDebug(PIC_LOG_DEBUG, "%s:%d break circle.", __FUNCTION__, __LINE__);
-				SDL_Delay(200);
-				break;
-			}
-		}
-	}
-
-	if (iPlayCount == m_nplay_cnt) {
-		m_pHostApi->PicDebug(PIC_LOG_INFO, "%d times picture playing task finished, exit.", iPlayCount);
-	}
-	else{
-		m_pHostApi->PicDebug(PIC_LOG_INFO, "user stop picture playing task, exit.");
-	}
-
-	SDL_HideWindow(m_window);
-	SDL_DestroyWindow(m_window);
-	m_window = NULL;
-	bRet = true;
-
-	return bRet;
-}
-
-
-int CPicturePlayer::StopPicPlay()
-{
-	int iRet = -1;
-	sem_post(&m_play_exit_sem);
-	m_busrstop = true;
-	m_pHostApi->PicDebug(PIC_LOG_DEBUG, "stop picture play, set user stop flag true.");
-
-	iRet = 0;
-
-	return iRet;
-}
-
-
-bool CPicturePlayer::GetPicPlayingFlag()
-{
-	m_pHostApi->PicDebug(PIC_LOG_DEBUG, "m_bplaying flag is %s", m_bplaying ? "true" : "false");
-	return m_bplaying;
-}
-
-
-bool CPicturePlayer::SetPicPlayingFlag(bool bret)
-{
-	m_bplaying = bret;
-	m_pHostApi->PicDebug(PIC_LOG_DEBUG, "after set m_bplaying flag is %s", m_bplaying ? "true" : "false");
-	return true;
-}

+ 0 - 99
Other/unix/libpictureplayer/CPicturePlayer.h

@@ -1,99 +0,0 @@
-#ifndef __CPICTURE_PLAYER_H__
-#define __CPICTURE_PLAYER_H__
-
-#include <stdio.h>
-#include <stdint.h>
-#include <stdbool.h>
-#include <semaphore.h>
-
-#include "ipicdatastruct.h"
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif // __cplusplus
-
-#if defined(_WIN32)
-#include <SDL.h>
-#include <SDL_video.h>
-#include <SDL_render.h>
-#include <SDL_rect.h>
-#include <SDL_mutex.h>
-#include <SDL_image.h>
-#else
-#include <SDL2/SDL.h>
-#include <SDL2/SDL_video.h>
-#include <SDL2/SDL_render.h>
-#include <SDL2/SDL_rect.h>
-#include <SDL2/SDL_mutex.h>
-#include <SDL2/SDL_image.h>
-#endif
-
-#ifdef __cplusplus
-}
-#endif // __cplusplus
-
-#ifndef MAX_FILECOUNT
-#define MAX_FILECOUNT 32
-#endif // !MAX_FILECOUNT
-
-#ifndef MAX_PATH
-#define MAX_PATH 260
-#endif
-
-#ifndef MAX_DISPLAYNUM
-#define MAX_DISPLAYNUM 5
-#endif // !MAX_DISPLAYNUM
-
-
-typedef struct rvc_picture_player_param_s {
-	int icx;
-	int icy;
-	uint8_t uwindow_width;
-	uint8_t uwindow_height;
-	bool bfull_screen;                           
-	bool bprim_monitor;                          
-	int nfile_cnt;		                        
-	int nplay_cnt;		                        
-	int nplay_interval;		                    
-	char strroot_path[MAX_PATH];		            
-	char strfile_names[MAX_FILECOUNT][MAX_PATH]; 
-}rvc_picture_player_param_t;
-
-
-class CPicturePlayer
-{
-public:
-	CPicturePlayer(CPicHostApi* pHostApi);
-	~CPicturePlayer();
-
-	int InitParam(rvc_picture_player_param_t* tparam);
-	int DeInit();
-	bool StartPicPlay();
-	int StopPicPlay();
-	bool GetPicPlayingFlag();
-	bool SetPicPlayingFlag(bool bret);
-	size_t GetVideoDisplayInfo();
-
-public:
-	SDL_Window* m_window;
-	CPicHostApi* m_pHostApi;
-	int m_nfile_cnt;
-	int m_nplay_cnt;
-	int m_nplay_interval;
-	char m_strroot_path[MAX_PATH];
-	char m_strfile_names[MAX_FILECOUNT][MAX_PATH];
-	int m_show_width;
-	int m_show_height;
-	bool m_busrstop;
-	
-private:
-	bool m_bplaying;
-	char* m_stricopath;
-	SDL_Thread* m_thid;
-	SDL_DisplayMode m_dispalymode[MAX_DISPLAYNUM];
-	sem_t m_play_exit_sem;
-};
-
-
-#endif

+ 0 - 54
Other/unix/libpictureplayer/ipicdatastruct.h

@@ -1,54 +0,0 @@
-#ifndef __I_PIC_DATA_STRUCT_H__
-#define __I_PIC_DATA_STRUCT_H__
-
-#ifdef RVC_OS_WIN
-#ifndef RVC_NO_VTABLE
-#define RVC_NO_VTABLE __declspec(novtable)
-#endif // !RVC_NO_VTABLE
-
-#else
-#ifndef RVC_NO_VTABLE
-#define RVC_NO_VTABLE 
-#endif // !RVC_NO_VTABLE
-#endif // RVC_OS_WIN
-
-#ifndef MAX_FILECOUNT
-#define MAX_FILECOUNT 32
-#endif // !MAX_FILECOUNT
-
-#ifndef MAX_PATH
-#define MAX_PATH 260
-#endif
-
-
-enum pic_loglevel{
-	PIC_LOG_DEBUG,
-	PIC_LOG_INFO,
-	PIC_LOG_ERROR,
-	PIC_LOG_NO
-};
-
-struct CPicPlayConfig
-{
-	bool bFullScreen;                           // 是否全屏
-	bool bPrimMonitor;                          // 是否主屏显示
-	int nWndX;                                  // 窗口X坐标
-	int nWndY;                                  // 窗口Y坐标
-	int nWndWidth;                              // 窗口宽度
-	int nWndHeight;                             // 窗口高度
-	int nFileCnt;		                        // 文件个数
-	int nPlayCnt;		                        // 播放次数
-	int nPlayInterval;		                    // 播放时间间隔
-	char strRootPath[MAX_PATH];		            // 根目录
-	char strFileNames[MAX_FILECOUNT][MAX_PATH]; // 文件名数组
-};
-
-
-struct RVC_NO_VTABLE CPicHostApi
-{
-	virtual void PicDebug(pic_loglevel elvel, const char* fmt, ...) = 0;
-	virtual int LoadPlayConfig(CPicPlayConfig& config, int CfgInx = 0) = 0;
-	virtual int GetPicPlayerIcoPath(char* strPath, size_t uLen) = 0;
-};
-
-#endif

+ 0 - 35
Other/unix/libpictureplayer/libpictureplayer.h

@@ -1,35 +0,0 @@
-#pragma once
-#include <stdio.h>
-#include "ipicdatastruct.h"
-
-#ifdef RVC_OS_WIN
-#ifdef LIBPICTUREPLAYER_EXPORTS
-#define LIBPICTUREPLAYER_API __declspec(dllexport)
-#else
-#define LIBPICTUREPLAYER_API __declspec(dllimport)
-#endif
-# elif ( defined(__GNUC__) &&  __GNUC__ >= 4 )
-#define LIBPICTUREPLAYER_API __attribute__((visibility("default")))
-#else // RVC_OS_WIN
-#define LIBPICTUREPLAYER_API
-#endif // RVC_OS_WIN
-
-
-class libpictureplayer_impl;
-
-
-class  LIBPICTUREPLAYER_API Clibpictureplayer
-{
-public:
-	Clibpictureplayer(CPicHostApi* pHostApi);
-	~Clibpictureplayer();
-
-	void Play(int nCfgInx, int nWndX, int nWndY, int nWndWidth, int nWndHeight);
-	void PlayMedia(CPicPlayConfig& config);
-	bool checkIsStop();
-	bool checkIsPlay(void* pthreadid);
-	void Close();
-
-private:
-	libpictureplayer_impl* m_pImpl;
-};

+ 0 - 2
Other/win/CMakeLists.txt

@@ -8,10 +8,8 @@ add_subdirectory(libbizchan)
 
 add_subdirectory(libimgplayer)
 add_subdirectory(libwmpplayer)
-add_subdirectory(libmediaplayer)
 add_subdirectory(libaudioqueue)
 # lack of SDL
-add_subdirectory(libpictureplayer)
 add_subdirectory(libaudiorender)
 add_subdirectory(libaudioframework)
 

+ 1 - 1
Other/win/libimgplayer/libimgplayer.h

@@ -25,7 +25,7 @@ struct CImgPlayConfig
 
 struct __declspec(novtable) CImgHostApi
 {
-	virtual BOOL LoadPlayConfig(CImgPlayConfig &config, int CfgInx = 0) = 0;
+	virtual bool LoadPlayConfig(CImgPlayConfig &config, int CfgInx = 0) = 0;
 	virtual void ImgDebug(const char *fmt, ...) = 0;
 };
 

+ 0 - 48
Other/win/libmediaplayer/ReadMe.txt

@@ -1,48 +0,0 @@
-========================================================================
-    DYNAMIC LINK LIBRARY : libmediaplayer Project Overview
-========================================================================
-
-AppWizard has created this libmediaplayer DLL for you.
-
-This file contains a summary of what you will find in each of the files that
-make up your libmediaplayer application.
-
-
-libmediaplayer.vcxproj
-    This is the main project file for VC++ projects generated using an Application Wizard.
-    It contains information about the version of Visual C++ that generated the file, and
-    information about the platforms, configurations, and project features selected with the
-    Application Wizard.
-
-libmediaplayer.vcxproj.filters
-    This is the filters file for VC++ projects generated using an Application Wizard. 
-    It contains information about the association between the files in your project 
-    and the filters. This association is used in the IDE to show grouping of files with
-    similar extensions under a specific node (for e.g. ".cpp" files are associated with the
-    "Source Files" filter).
-
-libmediaplayer.cpp
-    This is the main DLL source file.
-
-	When created, this DLL does not export any symbols. As a result, it
-	will not produce a .lib file when it is built. If you wish this project
-	to be a project dependency of some other project, you will either need to
-	add code to export some symbols from the DLL so that an export library
-	will be produced, or you can set the Ignore Input Library property to Yes
-	on the General propert page of the Linker folder in the project's Property
-	Pages dialog box.
-
-/////////////////////////////////////////////////////////////////////////////
-Other standard files:
-
-StdAfx.h, StdAfx.cpp
-    These files are used to build a precompiled header (PCH) file
-    named libmediaplayer.pch and a precompiled types file named StdAfx.obj.
-
-/////////////////////////////////////////////////////////////////////////////
-Other notes:
-
-AppWizard uses "TODO:" comments to indicate parts of the source code you
-should add to or customize.
-
-/////////////////////////////////////////////////////////////////////////////

+ 0 - 6
Other/win/libmediaplayer/audio.h

@@ -1,6 +0,0 @@
-#pragma once
-
-#include "player.h"
-
-int open_audio(player_stat_t *is);
-

+ 0 - 6
Other/win/libmediaplayer/demux.h

@@ -1,6 +0,0 @@
-#pragma once
-
-#include "player.h"
-
-int open_demux(player_stat_t *is);
-

+ 0 - 19
Other/win/libmediaplayer/dllmain.cpp

@@ -1,19 +0,0 @@
-// dllmain.cpp : Defines the entry point for the DLL application.
-#include "stdafx.h"
-
-BOOL APIENTRY DllMain( HMODULE hModule,
-                       DWORD  ul_reason_for_call,
-                       LPVOID lpReserved
-					 )
-{
-	switch (ul_reason_for_call)
-	{
-	case DLL_PROCESS_ATTACH:
-	case DLL_THREAD_ATTACH:
-	case DLL_THREAD_DETACH:
-	case DLL_PROCESS_DETACH:
-		break;
-	}
-	return TRUE;
-}
-

+ 0 - 151
Other/win/libmediaplayer/frame.cpp

@@ -1,151 +0,0 @@
-#include "frame.h"
-#include "player.h"
-
-void frame_queue_unref_item(frame_t *vp)
-{
-    av_frame_unref(vp->frame);
-}
-
-int frame_queue_init(frame_queue_t *f, packet_queue_t *pktq, int max_size, int keep_last)
-{
-    memset(f, 0, sizeof(frame_queue_t));
-    
-	if (!(f->frame_mutex = SDL_CreateMutex())) {
-        return AVERROR(ENOMEM);
-    }
-
-    if (!(f->frame_cond = SDL_CreateCond())) {
-        return AVERROR(ENOMEM);
-    }
-
-    f->pktq = pktq;
-    f->max_size = FFMIN(max_size, FRAME_QUEUE_SIZE);
-    f->keep_last = !!keep_last;
-
-	for (int i = 0; i < f->max_size; i++) {
-		if (!(f->queue[i].frame = av_frame_alloc())) {
-			return AVERROR(ENOMEM);
-		}
-	}
-
-    return 0;
-}
-
-void frame_queue_destory(frame_queue_t *f)
-{
-    for (int i = 0; i < f->max_size; i++) {
-        frame_t *vp = &f->queue[i];
-        frame_queue_unref_item(vp);
-        av_frame_free(&vp->frame);
-    }
-
-    SDL_DestroyMutex(f->frame_mutex);
-    SDL_DestroyCond(f->frame_cond);
-}
-
-void frame_queue_signal(frame_queue_t *f)
-{
-    SDL_LockMutex(f->frame_mutex);
-    SDL_CondSignal(f->frame_cond);
-    SDL_UnlockMutex(f->frame_mutex);
-}
-
-frame_t *frame_queue_peek(frame_queue_t *f)
-{
-    return &f->queue[(f->rindex + f->rindex_shown) % f->max_size];
-}
-
-frame_t *frame_queue_peek_next(frame_queue_t *f)
-{
-    return &f->queue[(f->rindex + f->rindex_shown + 1) % f->max_size];
-}
-
-// 取出此帧进行播放,只读取不删除,不删除是因为此帧需要缓存下来供下一次使用。播放后,此帧变为上一帧
-frame_t *frame_queue_peek_last(frame_queue_t *f)
-{
-    return &f->queue[f->rindex];
-}
-
-// 向队列尾部申请一个可写的帧空间,若无空间可写,则等待
-frame_t *frame_queue_peek_writable(frame_queue_t *f)
-{
-    /* wait until we have space to put a new frame */
-    SDL_LockMutex(f->frame_mutex);
-    while (f->size >= f->max_size && !f->pktq->abort_flag) {
-		SDL_CondWait(f->frame_cond, f->frame_mutex);
-    }
-    SDL_UnlockMutex(f->frame_mutex);
-
-	if (f->pktq->abort_flag) {
-		return NULL;
-	}
-
-    return &f->queue[f->windex];
-}
-
-// 从队列头部读取一帧,只读取不删除,若无帧可读则等待
-frame_t *frame_queue_peek_readable(frame_queue_t *f)
-{
-    /* wait until we have a readable a new frame */
-	bool bexit = false;
-    SDL_LockMutex(f->frame_mutex);
-    while (f->size - f->rindex_shown <= 0 && !f->pktq->abort_flag) {
-		SDL_CondWait(f->frame_cond, f->frame_mutex);
-    }
-    SDL_UnlockMutex(f->frame_mutex);
-
-	if (f->pktq->abort_flag || bexit) {
-		return NULL;
-	}
-
-    return &f->queue[(f->rindex + f->rindex_shown) % f->max_size];
-}
-
-// 向队列尾部压入一帧,只更新计数与写指针,因此调用此函数前应将帧数据写入队列相应位置
-void frame_queue_push(frame_queue_t *f)
-{
-	if (++f->windex == f->max_size) {
-		f->windex = 0;
-	}
-    SDL_LockMutex(f->frame_mutex);
-    f->size++;
-    SDL_CondSignal(f->frame_cond);
-    SDL_UnlockMutex(f->frame_mutex);
-}
-
-// 读指针(rindex)指向的帧已显示,删除此帧,注意不读取直接删除。读指针加1
-void frame_queue_next(frame_queue_t *f)
-{
-    if (f->keep_last && !f->rindex_shown) {
-        f->rindex_shown = 1;
-        return;
-    }
-    frame_queue_unref_item(&f->queue[f->rindex]);
-	if (++f->rindex == f->max_size) {
-		f->rindex = 0;
-	}
-    SDL_LockMutex(f->frame_mutex);
-    f->size--;
-	SDL_CondSignal(f->frame_cond);
-    SDL_UnlockMutex(f->frame_mutex);
-}
-
-// frame_queue中未显示的帧数
-/* return the number of undisplayed frames in the queue */
-int frame_queue_nb_remaining(frame_queue_t *f)
-{
-    return f->size - f->rindex_shown;
-}
-
-/* return last shown position */
-int64_t frame_queue_last_pos(frame_queue_t *f)
-{
-    frame_t *fp = &f->queue[f->rindex];
-	if (f->rindex_shown && fp->serial == f->pktq->serial) {
-		return fp->pos;
-	}
-	else {
-		return -1;
-	}
-}
-

+ 0 - 18
Other/win/libmediaplayer/frame.h

@@ -1,18 +0,0 @@
-#pragma once
-
-#include "player.h"
-
-void frame_queue_unref_item(frame_t *vp);
-int frame_queue_init(frame_queue_t *f, packet_queue_t *pktq, int max_size, int keep_last);
-void frame_queue_destory(frame_queue_t *f);
-void frame_queue_signal(frame_queue_t *f);
-frame_t *frame_queue_peek(frame_queue_t *f);
-frame_t *frame_queue_peek_next(frame_queue_t *f);
-frame_t *frame_queue_peek_last(frame_queue_t *f);
-frame_t *frame_queue_peek_writable(frame_queue_t *f);
-frame_t *frame_queue_peek_readable(frame_queue_t *f);
-void frame_queue_push(frame_queue_t *f);
-void frame_queue_next(frame_queue_t *f);
-int frame_queue_nb_remaining(frame_queue_t *f);
-int64_t frame_queue_last_pos(frame_queue_t *f);
-

+ 0 - 156
Other/win/libmediaplayer/packet.cpp

@@ -1,156 +0,0 @@
-#include "packet.h"
-
-int packet_queue_init(packet_queue_t *q, CMediaHostApi* hostapi)
-{
-    memset(q, 0, sizeof(packet_queue_t));
-
-    q->mutex = SDL_CreateMutex();
-    if (!q->mutex){
-		hostapi->Debug(MEDIA_LOG_DEBUG, "SDL_CreateMutex(): %s.", SDL_GetError());
-        return AVERROR(ENOMEM);
-    }
-
-    q->packet_cond = SDL_CreateCond();
-    if (!q->packet_cond){
-		hostapi->Debug(MEDIA_LOG_DEBUG, "SDL_CreateCond(): %s.", SDL_GetError());
-        return AVERROR(ENOMEM);
-    }
-    q->abort_flag = 0;
-
-    return 0;
-}
-
-
-// 写队列尾部。pkt是一包还未解码的音频数据
-int packet_queue_put(packet_queue_t *q, AVPacket *pkt, CMediaHostApi* hostapi)
-{
-	AVPacketList* pkt_list = NULL;
-
-    if (av_packet_make_refcounted(pkt) < 0){
-		hostapi->Debug(MEDIA_LOG_DEBUG, "[pkt] is not refrence counted.");
-        return -1;
-    }
-
-    pkt_list = (AVPacketList*)av_malloc(sizeof(AVPacketList));
-    if (!pkt_list){
-        return -1;
-    }
-    
-    pkt_list->pkt = *pkt;
-    pkt_list->next = NULL;
-
-    SDL_LockMutex(q->mutex);
-
-	// 队列为空
-    if (!q->last_pkt){
-        q->first_pkt = pkt_list;
-    }
-    else{
-        q->last_pkt->next = pkt_list;
-    }
-    q->last_pkt = pkt_list;
-    q->nb_packets++;
-    q->packet_queue_size += pkt_list->pkt.size;
-	//hostapi->Debug(MEDIA_LOG_DEBUG, "[%p] packet_queue_put current packet queue len is %d.", q, q->nb_packets);
-    // 发个条件变量的信号:重启等待q->cond条件变量的一个线程
-	SDL_CondSignal(q->packet_cond);
-
-    SDL_UnlockMutex(q->mutex);
-
-    return 0;
-}
-
-// 读队列头部。
-int packet_queue_get(packet_queue_t *q, AVPacket *pkt, int block, CMediaHostApi* hostapi)
-{
-    AVPacketList *p_pkt_node = NULL;
-
-    int ret = -1;
-
-    SDL_LockMutex(q->mutex);
-
-    while (0 == q->abort_flag)
-    {
-        p_pkt_node = q->first_pkt;
-        if (p_pkt_node)             // 队列非空,取一个出来
-        {
-            q->first_pkt = p_pkt_node->next;
-            if (!q->first_pkt)
-            {
-                q->last_pkt = NULL;
-            }
-            q->nb_packets--;
-			//hostapi->Debug(MEDIA_LOG_DEBUG, "[%p] packet_queue_get current packet queue len is %d.", q, q->nb_packets);
-            q->packet_queue_size -= p_pkt_node->pkt.size;
-            *pkt = p_pkt_node->pkt;
-            av_free(p_pkt_node);
-            ret = 1;
-            break;
-        }
-		else if (!block)            // 队列空且阻塞标志无效,则立即退出
-		{
-			ret = 0;
-			break;
-		}
-		else                        // 队列空且阻塞标志有效,则等待
-		{
-			if (SDL_MUTEX_TIMEDOUT == SDL_CondWaitTimeout(q->packet_cond, q->mutex, 1000)){
-				break;
-			}			
-		}
-    }
-    SDL_UnlockMutex(q->mutex);
-
-    return ret;
-}
-
-int packet_queue_put_nullpacket(packet_queue_t *q, int stream_index, CMediaHostApi* hostapi)
-{
-    AVPacket pkt1, *pkt = &pkt1;
-    av_init_packet(pkt);
-    pkt->data = NULL;
-    pkt->size = 0;
-    pkt->stream_index = stream_index;
-    return packet_queue_put(q, pkt, hostapi);
-}
-
-void packet_queue_flush(packet_queue_t *q)
-{
-    AVPacketList *pkt, *pkt1;
-
-    SDL_LockMutex(q->mutex);
-    for (pkt = q->first_pkt; pkt; pkt = pkt1) {
-        pkt1 = pkt->next;
-		if (pkt->pkt.size > 0)
-		{
-			q->packet_queue_size -= pkt->pkt.size;
-			av_packet_unref(&pkt->pkt);
-			av_freep(&pkt);
-			q->nb_packets--;
-		}
-    }
-    q->last_pkt = NULL;
-    q->first_pkt = NULL;
-    q->nb_packets = 0;
-    q->packet_queue_size = 0;
-    q->duration = 0;
-    SDL_UnlockMutex(q->mutex);
-}
-
-void packet_queue_destroy(packet_queue_t *q, CMediaHostApi* m_hostapi)
-{
-    packet_queue_flush(q);
-    SDL_DestroyMutex(q->mutex);
-    SDL_DestroyCond(q->packet_cond);
-	m_hostapi->Debug(MEDIA_LOG_DEBUG, "packet queue destroy.");
-}
-
-void packet_queue_abort(packet_queue_t *q, CMediaHostApi* m_hostapi)
-{
-    SDL_LockMutex(q->mutex);
-    q->abort_flag = 1;
-	m_hostapi->Debug(MEDIA_LOG_DEBUG, "packet_queue_abort, CondSignal cond.");
-    SDL_CondSignal(q->packet_cond);
-    SDL_UnlockMutex(q->mutex);
-}
-

+ 0 - 602
Other/win/libmediaplayer/player.cpp

@@ -1,602 +0,0 @@
-#include <stdio.h>
-//#include <stdbool.h>
-#include <assert.h>
-
-#include "player.h"
-#include "frame.h"
-#include "packet.h"
-#include "demux.h"
-#include "video.h"
-#include "audio.h"
-
-
-static int initialized = 0;
-
-// 返回值:返回上一帧的pts更新值(上一帧pts+流逝的时间)
-double get_clock(play_clock_t *c)
-{
-    if (*c->queue_serial != c->serial)
-    {
-        return NAN;
-    }
-    if (c->paused)
-    {
-        return c->pts;
-    }
-    else
-    {
-        double time = av_gettime_relative() / 1000000.0;
-        double ret = c->pts_drift + time;   // 展开得: c->pts + (time - c->last_updated)
-        return ret;
-    }
-}
-
-
-void set_clock_at(play_clock_t *c, double pts, int serial, double time)
-{
-    c->pts = pts;
-    c->last_updated = time;
-    c->pts_drift = c->pts - time;
-    c->serial = serial;
-}
-
-
-void set_clock(play_clock_t *c, double pts, int serial)
-{
-    double time = av_gettime_relative() / 1000000.0;
-    set_clock_at(c, pts, serial, time);
-}
-
-
-static void set_clock_speed(play_clock_t *c, double speed)
-{
-    set_clock(c, get_clock(c), c->serial);
-    c->speed = speed;
-}
-
-
-void init_clock(play_clock_t *c, int *queue_serial)
-{
-    c->speed = 1.0;
-    c->paused = 0;
-    c->queue_serial = queue_serial;
-    set_clock(c, NAN, -1);
-}
-
-
-static void sync_play_clock_to_slave(play_clock_t *c, play_clock_t *slave)
-{
-    double clock = get_clock(c);
-    double slave_clock = get_clock(slave);
-    if (!isnan(slave_clock) && (isnan(clock) || fabs(clock - slave_clock) > AV_NOSYNC_THRESHOLD))
-        set_clock(c, slave_clock, slave->serial);
-}
-
-/* pause or resume the video */
-static void stream_toggle_pause(player_stat_t *is)
-{
-    if (is->paused)
-    {
-        // 这里表示当前是暂停状态,将切换到继续播放状态。在继续播放之前,先将暂停期间流逝的时间加到frame_timer中
-        is->frame_timer += av_gettime_relative() / 1000000.0 - is->video_clk.last_updated;
-        set_clock(&is->video_clk, get_clock(&is->video_clk), is->video_clk.serial);
-    }
-    is->paused = is->audio_clk.paused = is->video_clk.paused = !is->paused;
-}
-
-
-static void toggle_pause(player_stat_t *is)
-{
-    stream_toggle_pause(is);
-    is->step = 0;
-}
-
-static void toggle_full_screen(player_stat_t* is)
-{
-	SDL_SetWindowFullscreen(is->sdl_video.window, SDL_WINDOW_FULLSCREEN_DESKTOP);
-}
-
-
-CMediaPlayer::CMediaPlayer(CMediaHostApi* pHostApi)
-{
-	m_hostapi = pHostApi;
-	m_player_stat = NULL;
-	m_uvolume = SDL_MIX_MAXVOLUME/2;
-	m_bplaying = false;
-	m_piconpath = NULL;
-	m_paudiodev = NULL;
-	
-	if (NULL != m_hostapi){
-		char str_iconpath[MAX_PATH] = {0};
-		if (0 == pHostApi->GetMediaPlayerIcoPath(str_iconpath, MAX_PATH)){
-			m_piconpath = av_strdup(str_iconpath);
-		}
-
-		char str_audiodev[MAX_PATH] = { 0 };
-		if (0 == pHostApi->GetAudioOutDevName(str_audiodev, MAX_PATH)) {
-			m_paudiodev = av_strdup(str_audiodev);
-		}
-		else {
-			m_paudiodev = NULL;
-		}
-	}
-	else {
-		m_hostapi->Debug(MEDIA_LOG_DEBUG, "new CMediaPlayer failed!");
-	}
-
-	if (initialized){
-		++initialized;
-	}
-	else {
-		if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_TIMER)){
-			m_hostapi->Debug(MEDIA_LOG_ERROR, "Could not initialize SDL - %s", SDL_GetError());
-			m_hostapi->Debug(MEDIA_LOG_ERROR, "(Did you set the DISPLAY variable?)");
-		}
-		else {
-			initialized++;
-			m_hostapi->Debug(MEDIA_LOG_DEBUG, "initialize SDL success");
-		}
-	}
-}
-
-CMediaPlayer::~CMediaPlayer()
-{
-	if (NULL != m_player_stat) {
-		UnInitialize_Player_Stat();
-	}
-
-	if (NULL != m_piconpath) {
-		av_free(m_piconpath);
-		m_piconpath = NULL;
-	}
-
-	if (NULL != m_paudiodev){
-		av_free(m_paudiodev);
-		m_paudiodev = NULL;
-	}
-
-	if (--initialized == 0){
-		//SDL_Quit();
-		m_hostapi->Debug(MEDIA_LOG_ERROR, "SDL_Quit");
-	}
-}
-
-
-static int audio_volume_callback(int* audiovolume, void* userdata)
-{
-	CMediaPlayer* player = (CMediaPlayer*)userdata;
-	*audiovolume = player->GetVolume();
-	return 0;
-}
-
-
-static int audio_play_finished_callback(void* userdata)
-{
-	CMediaPlayer* player = (CMediaPlayer*)userdata;
-	if (NULL != player){
-		player->SetFinishedFlag();
-	}
-	return 0;
-}
-
-bool CMediaPlayer::SetFinishedFlag()
-{
-	if (NULL != m_player_stat){
-		//m_player_stat->baudio_finished = true;
-		if (NULL != m_hostapi) {
-			m_hostapi->Debug(MEDIA_LOG_ERROR, "%s:%d set baudio_finished to true.", __FUNCTION__, __LINE__);
-		}
-	}
-	else {
-		if (NULL != m_hostapi) {
-			m_hostapi->Debug(MEDIA_LOG_ERROR, "%s:%d m_player_stat is null and set audio finished flag failed.", __FUNCTION__, __LINE__);
-		}
-	}
-	
-	return true;
-}
-
-uint8_t CMediaPlayer::GetVolume()
-{
-	return m_uvolume;
-}
-
-eMediaType_t CMediaPlayer::GetPlayingMediaType()
-{
-	return m_player_stat->eMType;
-}
-
-int CMediaPlayer::Initialize_Player_Stat(rvc_media_player_param_t* pMedia_Player)
-{
-	int iRet = -1;
-
-	if (NULL == pMedia_Player) {
-		return iRet;
-	}
-
-	if (NULL != m_player_stat) {
-		UnInitialize_Player_Stat();
-	}
-
-	m_player_stat = (player_stat_t*)av_mallocz(sizeof(player_stat_t));
-	if (NULL == m_player_stat) {
-		m_hostapi->Debug(MEDIA_LOG_DEBUG, "player_stat_t struct malloc failed!");
-		return iRet;
-	}
-
-	m_player_stat->buser_stop = false;
-	m_player_stat->rvc_hostapi = m_hostapi;
-	m_player_stat->prvc_cb = pMedia_Player->cb;
-	m_player_stat->eMType = pMedia_Player->eType;
-	m_player_stat->eWindType = pMedia_Player->eWindType;
-	m_player_stat->bvice_monitor = pMedia_Player->bvicemonitor;
-	m_player_stat->iDisplayCx = pMedia_Player->idisplaycx;
-	m_player_stat->iDisplayCy = pMedia_Player->idisplaycy;
-	m_player_stat->iDisplayWidth = pMedia_Player->idisplaywidth;
-	m_player_stat->iDisplayHeight = pMedia_Player->idisplayheight;
-	m_player_stat->on_audio_volume = &audio_volume_callback;
-	m_player_stat->on_audio_play_finished = &audio_play_finished_callback;
-	m_player_stat->user_data = this;
-	if (NULL != m_piconpath){
-		m_player_stat->piconpath = av_strdup(m_piconpath);
-	}
-
-	if (NULL != m_paudiodev){
-		m_player_stat->paudiodev = av_strdup(m_paudiodev);
-	}
-	m_player_stat->uVolume = m_uvolume;
-	m_player_stat->uFilesCount = pMedia_Player->uFilesCount;
-	m_player_stat->icurrent_index = 0;
-	m_player_stat->iaudio_dec_index = 0;
-	for (size_t i = 0; i < pMedia_Player->uFilesCount; i++){
-		memcpy(m_player_stat->strPlayLists[i], pMedia_Player->strPlayLists[i], strlen(pMedia_Player->strPlayLists[i]));
-	}
-
-	if (0 == pMedia_Player->uFilesCount || NULL == m_player_stat->rvc_hostapi || NULL == m_player_stat->prvc_cb || NULL == m_player_stat->piconpath) {
-		UnInitialize_Player_Stat();
-		return iRet;
-	}
-	else{
-		iRet = 0;
-	}
-
-	return iRet;
-}
-
-
-int CMediaPlayer::UnInitialize_Player_Stat()
-{
-	/* XXX: use a special url_shutdown call to abort parse cleanly */
-	if (NULL == m_player_stat) {
-		return -1;
-	}
-
-	if (NULL != m_player_stat->read_tid){
-		SDL_WaitThread(m_player_stat->read_tid, NULL);
-		m_player_stat->read_tid = NULL;
-		m_hostapi->Debug(MEDIA_LOG_DEBUG, "demux thread finished.");
-	}
-
-	for (int index = 0; index < m_player_stat->uFilesCount; index++) {
-		if (NULL != m_player_stat->p_fmt_ctx[index]) {
-			avformat_close_input(&m_player_stat->p_fmt_ctx[index]);
-			avformat_free_context(m_player_stat->p_fmt_ctx[index]);
-			m_player_stat->p_fmt_ctx[index] = NULL;
-		}
-
-		if (NULL != m_player_stat->p_acodec_ctx[index]) {
-			avcodec_close(m_player_stat->p_acodec_ctx[index]);
-			avcodec_free_context(&m_player_stat->p_acodec_ctx[index]);
-		}
-
-		if (NULL != m_player_stat->p_vcodec_ctx[index]) {
-			avcodec_close(m_player_stat->p_vcodec_ctx[index]);
-			avcodec_free_context(&m_player_stat->p_vcodec_ctx[index]);
-		}
-	}
-	
-	SDL_DestroyCond(m_player_stat->continue_read_thread);
-	SDL_DestroyCond(m_player_stat->audio_play_cond);
-	SDL_DestroyMutex(m_player_stat->audio_play_wait_mutex);
-
-	if (m_player_stat->eMType == eVideo_Type) {
-		for (int index = 0; index < m_player_stat->uFilesCount; index++) {
-			if (NULL != m_player_stat->img_convert_ctx[index]) {
-				sws_freeContext(m_player_stat->img_convert_ctx[index]);
-				m_player_stat->img_convert_ctx[index] = NULL;
-			}
-			if (NULL != m_player_stat->p_frm_yuv[index]) {
-				av_frame_free(&m_player_stat->p_frm_yuv[index]);
-				av_frame_unref(m_player_stat->p_frm_yuv[index]);
-			}
-			if (NULL != m_player_stat->p_video_buffer[index]) {
-				av_free(m_player_stat->p_video_buffer[index]);
-				m_player_stat->p_video_buffer[index] = NULL;
-			}
-		}
-	}
-
-	packet_queue_destroy(&m_player_stat->video_pkt_queue, m_hostapi);
-	packet_queue_destroy(&m_player_stat->audio_pkt_queue, m_hostapi);
-
-	///* free all pictures */
-	frame_queue_destory(&m_player_stat->video_frm_queue);
-	frame_queue_destory(&m_player_stat->audio_frm_queue);
-
-	m_hostapi->Debug(MEDIA_LOG_DEBUG, "av_free player_stat_t.");
-
-	swr_free(&m_player_stat->audio_swr_ctx);
-
-	if (NULL != m_player_stat->audio_frm_rwr) {
-		av_free(m_player_stat->audio_frm_rwr);
-		m_player_stat->audio_frm_rwr = NULL;
-	}
-
-	if (m_player_stat->piconpath){
-		av_free(m_player_stat->piconpath);
-		m_player_stat->piconpath = NULL;
-	}
-
-	if (m_player_stat->paudiodev) {
-		av_free(m_player_stat->paudiodev);
-		m_player_stat->paudiodev = NULL;
-	}
-
-	if (m_player_stat->straudiodev) {
-		av_free(m_player_stat->straudiodev);
-		m_player_stat->straudiodev = NULL;
-	}
-
-	av_free(m_player_stat);
-	m_player_stat = NULL;
-
-	return 0;
-}
-
-int CMediaPlayer::GetViceVideoDisplayInfo(int* icx, int* icy, int* iwidth, int* iheight)
-{
-	int iRet = -1;
-	size_t uCount = SDL_GetNumVideoDisplays();
-	m_hostapi->Debug(MEDIA_LOG_DEBUG, "VideoDisplays Number is %d.", uCount);
-	SDL_DisplayMode dispalymode[RVC_MAX_DISPLAYNUM] = { 0 };
-	for (size_t i = 0; i < uCount && i < RVC_MAX_DISPLAYNUM; i++) {
-		SDL_GetDesktopDisplayMode(i, &dispalymode[i]);
-		m_hostapi->Debug(MEDIA_LOG_DEBUG, "VideoDisplays{%d} format = %d", i, dispalymode[i].format);
-		m_hostapi->Debug(MEDIA_LOG_DEBUG, "VideoDisplays{%d} w = %d", i, dispalymode[i].w);
-		m_hostapi->Debug(MEDIA_LOG_DEBUG, "VideoDisplays{%d} h = %d", i, dispalymode[i].h);
-		m_hostapi->Debug(MEDIA_LOG_DEBUG, "VideoDisplays{%d} refresh_rate = %d", i, dispalymode[i].refresh_rate);
-	}
-	if (uCount > 1) {
-		*icx = dispalymode[0].w;
-		*icy = 0;
-		*iwidth = dispalymode[1].w;
-		*iheight = dispalymode[1].h;
-		iRet = 0;
-	}
-
-	return iRet;
-}
-
-int CMediaPlayer::InitParam(rvc_media_player_param_t* pMedia_Player)
-{
-	int iRet = -1;
-
-	if (0 != Initialize_Player_Stat(pMedia_Player)){
-		return iRet;
-	}
-	m_hostapi->Debug(MEDIA_LOG_DEBUG, "initialize player stat success.");
-	/* start video display */
-	if (frame_queue_init(&m_player_stat->video_frm_queue, &m_player_stat->video_pkt_queue, VIDEO_PICTURE_QUEUE_SIZE, 1) < 0 ||
-		frame_queue_init(&m_player_stat->audio_frm_queue, &m_player_stat->audio_pkt_queue, SAMPLE_QUEUE_SIZE, 1) < 0)
-	{
-		m_hostapi->Debug(MEDIA_LOG_DEBUG, "media frame queue init failed!");
-		UnInitialize_Player_Stat();
-		return iRet;
-	}
-	else{
-		m_hostapi->Debug(MEDIA_LOG_DEBUG, "frame queue init success!");
-	}
-
-	/* init packet queue */
-	if (packet_queue_init(&m_player_stat->video_pkt_queue, m_hostapi) < 0 ||
-		packet_queue_init(&m_player_stat->audio_pkt_queue, m_hostapi) < 0)
-	{
-		m_hostapi->Debug(MEDIA_LOG_DEBUG, "media packet queue init failed!");
-		UnInitialize_Player_Stat();
-		return iRet;
-	}
-	else{
-		m_hostapi->Debug(MEDIA_LOG_DEBUG, "packet queue audio[%p] video[%p] init success!", &m_player_stat->audio_pkt_queue, &m_player_stat->video_pkt_queue);
-	}
-
-	/* put end pkt into packet queue */
-	AVPacket flush_pkt = {0};
-	flush_pkt.data = NULL;
-	packet_queue_put(&m_player_stat->video_pkt_queue, &flush_pkt, m_hostapi);
-	packet_queue_put(&m_player_stat->audio_pkt_queue, &flush_pkt, m_hostapi);
-
-	if (!(m_player_stat->continue_read_thread = SDL_CreateCond()) || !(m_player_stat->audio_play_cond = SDL_CreateCond())){
-		m_hostapi->Debug(MEDIA_LOG_DEBUG, "SDL_CreateCond(): %s.", SDL_GetError());
-		UnInitialize_Player_Stat();
-		return iRet;
-	}
-
-	m_player_stat->audio_play_wait_mutex = SDL_CreateMutex();
-
-	init_clock(&m_player_stat->video_clk, &m_player_stat->video_pkt_queue.serial);
-	init_clock(&m_player_stat->audio_clk, &m_player_stat->audio_pkt_queue.serial);
-
-	if (m_player_stat->bvice_monitor){
-		if (0 == GetViceVideoDisplayInfo(&m_player_stat->iDisplayCx, &m_player_stat->iDisplayCy, &m_player_stat->iDisplayWidth, &m_player_stat->iDisplayHeight)){
-			m_hostapi->Debug(MEDIA_LOG_DEBUG, "Get Vice Video Display Info Success.");
-		}
-	}
-	
-	m_hostapi->Debug(MEDIA_LOG_DEBUG, "display cx is %d, cy is %d, width is %d, height is %d.", m_player_stat->iDisplayCx, m_player_stat->iDisplayCy, m_player_stat->iDisplayWidth, m_player_stat->iDisplayHeight);
-
-	iRet = 0;
-
-	return iRet;
-}
-
-
-int CMediaPlayer::SetVolume(uint8_t uVolume)
-{
-	int iRet = -1;
-	
-	m_uvolume = uVolume * SDL_MIX_MAXVOLUME/100;
-
-	m_hostapi->Debug(MEDIA_LOG_DEBUG, "set audio volume(%d) to %d.", uVolume, m_uvolume);
-
-	iRet = 0;
-
-	return iRet;
-}
-
-
-bool CMediaPlayer::GetPlayingFlag()
-{
-	return m_bplaying;
-}
-
-
-int CMediaPlayer::StartMediaPlay()
-{
-	int iRet = -1;
-	if (0 == open_demux(m_player_stat)){
-		m_hostapi->Debug(MEDIA_LOG_DEBUG, "open_demux function call success.");
-	}
-	else{
-		m_hostapi->Debug(MEDIA_LOG_ERROR, "open_demux function call failed.");
-		av_free(m_player_stat);
-		m_player_stat = NULL;
-		iRet = -3;
-		return iRet;
-	}
-
-	m_hostapi->Debug(MEDIA_LOG_DEBUG, "set playing flag to true.");
-	m_bplaying = true;
-
-	if (eVideo_Type == m_player_stat->eMType) {
-		open_video(m_player_stat);
-	}
-
-	open_audio(m_player_stat);
-
-	m_hostapi->Debug(MEDIA_LOG_DEBUG, "after open_audio function.");
-
-	if (NULL != m_player_stat->audio_decode_tid) {
-		SDL_WaitThread(m_player_stat->audio_decode_tid, NULL);
-		m_player_stat->audio_decode_tid = NULL;
-		m_hostapi->Debug(MEDIA_LOG_DEBUG, "audio decode thread finished.");
-	}
-
-	if (m_player_stat->eMType == eVideo_Type) {
-		if (NULL != m_player_stat->video_decode_tid) {
-			SDL_WaitThread(m_player_stat->video_decode_tid, NULL);
-			m_player_stat->video_decode_tid = NULL;
-			m_hostapi->Debug(MEDIA_LOG_DEBUG, "video decode thread finished.");
-		}
-
-		if (NULL != m_player_stat->video_playing_tid) {
-			SDL_WaitThread(m_player_stat->video_playing_tid, NULL);
-			m_player_stat->video_playing_tid = NULL;
-			m_hostapi->Debug(MEDIA_LOG_DEBUG, "video playing thread finished.");
-		}
-	}
-
-	ExitMediaPlayingThread();
-
-	iRet = 0;
-	
-	return iRet;
-}
-
-
-int CMediaPlayer::StopMediaPlay()
-{
-	int iRet = -1;
-
-	m_hostapi->Debug(MEDIA_LOG_DEBUG, "StopMediaPlay called.");
-
-	if (NULL == m_player_stat) {
-		return iRet;
-	}
-
-	packet_queue_abort(&m_player_stat->video_pkt_queue, m_hostapi);
-	packet_queue_abort(&m_player_stat->audio_pkt_queue, m_hostapi);
-
-	frame_queue_signal(&m_player_stat->video_frm_queue);
-	frame_queue_signal(&m_player_stat->audio_frm_queue);
-
-	m_hostapi->Debug(MEDIA_LOG_ERROR, "%s:%d set m_player_stat media finished flag to true.", __FUNCTION__, __LINE__);
-	m_player_stat->buser_stop = true;
-
-	if (m_bplaying) {
-		m_hostapi->Debug(MEDIA_LOG_DEBUG, "user stop audio play set SDL_PauseAudioDevice param to 1.");
-		if (0 != audio_dev){
-			SDL_PauseAudioDevice(audio_dev, 1);
-		}
-	}
-
-	iRet = 0;
-
-	return iRet;
-}
-
-
-int CMediaPlayer::ExitMediaPlayingThread()
-{
-	int iRet = -1;
-
-	if (NULL == m_player_stat){
-		return iRet;
-	}
-
-	m_hostapi->Debug(MEDIA_LOG_DEBUG, "enter ExitMediaPlayingThread call.");
-
-	if(eVideo_Type == m_player_stat->eMType){
-		if (m_player_stat->sdl_video.texture) {
-			SDL_DestroyTexture(m_player_stat->sdl_video.texture);
-		}
-
-		if (m_player_stat->sdl_video.renderer){
-			SDL_DestroyRenderer(m_player_stat->sdl_video.renderer);
-		}
-		
-		if (m_player_stat->sdl_video.window){
-			SDL_DestroyWindow(m_player_stat->sdl_video.window);
-			m_hostapi->Debug(MEDIA_LOG_ERROR, "Destroy Window.");
-		}
-	}
-
-	if (m_player_stat->prvc_cb){
-		m_hostapi->Debug(MEDIA_LOG_DEBUG, "cb_play_media_finished callback.");
-		m_player_stat->prvc_cb->cb_play_media_finished(m_player_stat->prvc_cb->user_data);
-	}
-
-	UnInitialize_Player_Stat();
-
-	m_bplaying = false;
-
-	iRet = 0;
-	
-	m_hostapi->Debug(MEDIA_LOG_DEBUG, "Leave ExitMediaPlayingThread call.");
-
-	return iRet;
-}
-
-
-int64_t CMediaPlayer::GetMediaPlayingThreadId()
-{
-	int64_t iRet = 0;
-	if (NULL != m_player_stat)
-	{
-		if (NULL != m_player_stat->read_tid)
-		{
-			iRet = SDL_GestureID(m_player_stat->read_tid);
-		}
-	}
-
-	return iRet;
-}

+ 0 - 8
Other/win/libmediaplayer/stdafx.cpp

@@ -1,8 +0,0 @@
-// stdafx.cpp : source file that includes just the standard includes
-// libmediaplayer.pch will be the pre-compiled header
-// stdafx.obj will contain the pre-compiled type information
-
-#include "stdafx.h"
-
-// TODO: reference any additional headers you need in STDAFX.H
-// and not in this file

+ 0 - 16
Other/win/libmediaplayer/stdafx.h

@@ -1,16 +0,0 @@
-// stdafx.h : include file for standard system include files,
-// or project specific include files that are used frequently, but
-// are changed infrequently
-//
-
-#pragma once
-
-#include "targetver.h"
-
-#define WIN32_LEAN_AND_MEAN             // Exclude rarely-used stuff from Windows headers
-// Windows Header Files:
-#include <windows.h>
-
-
-
-// TODO: reference additional headers your program requires here

+ 0 - 8
Other/win/libmediaplayer/targetver.h

@@ -1,8 +0,0 @@
-#pragma once
-
-// Including SDKDDKVer.h defines the highest available Windows platform.
-
-// If you wish to build your application for a previous Windows platform, include WinSDKVer.h and
-// set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h.
-
-#include <SDKDDKVer.h>

+ 0 - 7
Other/win/libmediaplayer/video.h

@@ -1,7 +0,0 @@
-#pragma once
-
-#include "player.h"
-
-int open_video(player_stat_t *is);
-
-

+ 0 - 48
Other/win/libpictureplayer/ReadMe.txt

@@ -1,48 +0,0 @@
-========================================================================
-    DYNAMIC LINK LIBRARY : libpictureplayer Project Overview
-========================================================================
-
-AppWizard has created this libpictureplayer DLL for you.
-
-This file contains a summary of what you will find in each of the files that
-make up your libpictureplayer application.
-
-
-libpictureplayer.vcxproj
-    This is the main project file for VC++ projects generated using an Application Wizard.
-    It contains information about the version of Visual C++ that generated the file, and
-    information about the platforms, configurations, and project features selected with the
-    Application Wizard.
-
-libpictureplayer.vcxproj.filters
-    This is the filters file for VC++ projects generated using an Application Wizard. 
-    It contains information about the association between the files in your project 
-    and the filters. This association is used in the IDE to show grouping of files with
-    similar extensions under a specific node (for e.g. ".cpp" files are associated with the
-    "Source Files" filter).
-
-libpictureplayer.cpp
-    This is the main DLL source file.
-
-	When created, this DLL does not export any symbols. As a result, it
-	will not produce a .lib file when it is built. If you wish this project
-	to be a project dependency of some other project, you will either need to
-	add code to export some symbols from the DLL so that an export library
-	will be produced, or you can set the Ignore Input Library property to Yes
-	on the General propert page of the Linker folder in the project's Property
-	Pages dialog box.
-
-/////////////////////////////////////////////////////////////////////////////
-Other standard files:
-
-StdAfx.h, StdAfx.cpp
-    These files are used to build a precompiled header (PCH) file
-    named libpictureplayer.pch and a precompiled types file named StdAfx.obj.
-
-/////////////////////////////////////////////////////////////////////////////
-Other notes:
-
-AppWizard uses "TODO:" comments to indicate parts of the source code you
-should add to or customize.
-
-/////////////////////////////////////////////////////////////////////////////

+ 0 - 19
Other/win/libpictureplayer/dllmain.cpp

@@ -1,19 +0,0 @@
-// dllmain.cpp : Defines the entry point for the DLL application.
-#include "stdafx.h"
-
-BOOL APIENTRY DllMain( HMODULE hModule,
-                       DWORD  ul_reason_for_call,
-                       LPVOID lpReserved
-					 )
-{
-	switch (ul_reason_for_call)
-	{
-	case DLL_PROCESS_ATTACH:
-	case DLL_THREAD_ATTACH:
-	case DLL_THREAD_DETACH:
-	case DLL_PROCESS_DETACH:
-		break;
-	}
-	return TRUE;
-}
-

+ 0 - 283
Other/win/libpictureplayer/libpictureplayer.cpp

@@ -1,283 +0,0 @@
-#include "libpictureplayer.h"
-#include "CPicturePlayer.h"
-//#include <unistd.h>
-#include <string.h>
-#include <process.h>
-#include <io.h>
-
-
-static unsigned int __stdcall PicturePlayingFunc(void* param) 
-{
-	CPicturePlayer* is = (CPicturePlayer*)param;
-
-	is->m_pHostApi->PicDebug(PIC_LOG_DEBUG, "enter PicturePlayingFunc");
-
-	is->StartPicPlay();
-
-	is->SetPicPlayingFlag(false);
-
-	is->m_pHostApi->PicDebug(PIC_LOG_DEBUG, "leave PicturePlayingFunc");
-
-	return 0;
-}
-
-
-class libpictureplayer_impl
-{
-public:
-	CPicPlayConfig m_stPlayConfig;
-	CPicHostApi* m_pHostApi;
-	CPicturePlayer* m_Player;
-	bool m_bIsPlay;
-	//pthread_t m_PlayThreadId;
-	HANDLE m_PlayThread;
-
-public:
-	libpictureplayer_impl(CPicHostApi* pHostApi) {
-		m_bIsPlay = false;
-		m_pHostApi = pHostApi;
-		memset(&m_stPlayConfig, 0, sizeof(m_stPlayConfig));
-		m_Player = new CPicturePlayer(pHostApi);
-		if (NULL == m_Player) {
-			pHostApi->PicDebug(PIC_LOG_DEBUG, "new PicturePlayer failed!");
-		}
-		m_PlayThread = NULL;
-	}
-
-	~libpictureplayer_impl()
-	{
-		m_pHostApi = NULL;
-		delete m_Player;
-		m_Player = NULL;
-		m_bIsPlay = false;
-		m_PlayThread = NULL;
-	}
-
-	bool isStop() 
-	{
-		//return !m_bIsPlay;
-		return !m_Player->GetPicPlayingFlag();
-	}
-
-	bool CheckIsPlay(void* pthreadid)
-	{
-		bool bret = false;
-		HANDLE threadHandle = m_PlayThread;
-		if (NULL != threadHandle)
-		{
-			bret = true;
-			*(HANDLE*)pthreadid = threadHandle;
-		}
-
-		return bret;
-	}
-
-	bool StartPlayMedia(CPicPlayConfig& config)
-	{
-		bool bRet = false;
-		//if (m_bIsPlay){
-		//	return true;
-		//}
-
-		memcpy(&m_stPlayConfig, &config, sizeof(CPicPlayConfig));
-
-		rvc_picture_player_param_t tplayer_param = { 0 };
-		tplayer_param.icx = m_stPlayConfig.nWndX;
-		tplayer_param.icy = m_stPlayConfig.nWndY;
-		tplayer_param.uwindow_width = m_stPlayConfig.nWndWidth;
-		tplayer_param.uwindow_height = m_stPlayConfig.nWndHeight;
-
-		tplayer_param.bfull_screen = m_stPlayConfig.bFullScreen;
-		tplayer_param.nplay_cnt = m_stPlayConfig.nPlayCnt;
-		tplayer_param.nplay_interval = m_stPlayConfig.nPlayInterval;
-
-		char strFileName[MAX_PATH] = { 0 };
-		_snprintf(strFileName, MAX_PATH, "%s%s", m_stPlayConfig.strRootPath, m_stPlayConfig.strFileNames[0]);
-		if (IsFileExist(strFileName)) {
-			memcpy(tplayer_param.strfile_names[0], strFileName, strlen(strFileName));
-			tplayer_param.nfile_cnt = 1;
-		}
-		else {
-			m_pHostApi->PicDebug(PIC_LOG_DEBUG, "File %s is not exist.", strFileName);
-			tplayer_param.nfile_cnt = 0;
-		}
-		
-
-		//if (0 == GetPicturePlayingParams(&tplayer_param)) 
-		{
-			if (0 == m_Player->InitParam(&tplayer_param))
-			{
-				m_pHostApi->PicDebug(PIC_LOG_DEBUG, "init picture player success and begin start picture play.");
-				m_PlayThread = (HANDLE)_beginthreadex(NULL, 0, &PicturePlayingFunc, m_Player, 0, NULL);
-				if (NULL != m_PlayThread) {
-					m_pHostApi->PicDebug(PIC_LOG_DEBUG, "create picture play thread success.");
-					m_bIsPlay = true;
-					bRet = true;
-					m_pHostApi->PicDebug(PIC_LOG_DEBUG, "start picture play Success.");
-				}
-				else {
-					m_pHostApi->PicDebug(PIC_LOG_DEBUG, "create picture play thread failed.");
-				}
-			}
-			else {
-				m_pHostApi->PicDebug(PIC_LOG_ERROR, "init picture player failed!");
-			}
-		}
-		//else {
-		//	m_pHostApi->PicDebug("get picture playing params failed!");
-		//}
-
-		return bRet;
-	}
-
-	int GetPicturePlayingParams(rvc_picture_player_param_t* pParam)
-	{
-		int iRet = -1;
-		if (NULL == pParam) {
-			return iRet;
-		}
-
-		pParam->bfull_screen = m_stPlayConfig.bFullScreen;
-		pParam->nplay_cnt = m_stPlayConfig.nPlayCnt;
-		pParam->nplay_interval = m_stPlayConfig.nPlayInterval;
-
-		size_t uValidCount = 0;
-		for (int i = 0; i < m_stPlayConfig.nFileCnt && i < MAX_FILECOUNT; i++) {
-			char strFileName[MAX_PATH] = { 0 };
-			_snprintf(strFileName, MAX_PATH, "%s%s", m_stPlayConfig.strRootPath, m_stPlayConfig.strFileNames[i]);
-			if (IsFileExist(strFileName)) {
-				memcpy(pParam->strfile_names[i], strFileName, strlen(strFileName));
-				uValidCount++;
-			}
-			else {
-				m_pHostApi->PicDebug(PIC_LOG_DEBUG, "File %s is not exist.", strFileName);
-				continue;
-			}
-		}
-		pParam->nfile_cnt = uValidCount;
-		if (NULL != m_pHostApi) {
-			m_pHostApi->PicDebug(PIC_LOG_DEBUG, "pParam uFilesCount = %d", uValidCount);
-		}
-		if (uValidCount > 0) {
-			iRet = 0;
-		}
-
-		return iRet;
-	}
-
-	bool StartPlay(int nCfgInx, int nWndX, int nWndY, int nWndWidth, int nWndHeight)
-	{
-		bool bRet = false;
-		if (true == m_Player->GetPicPlayingFlag()){
-			m_pHostApi->PicDebug(PIC_LOG_DEBUG, "now is playing!");
-			return true;
-		}
-
-		int iRet = m_pHostApi->LoadPlayConfig(m_stPlayConfig, nCfgInx);
-		if (0 != iRet){
-			m_pHostApi->PicDebug(PIC_LOG_DEBUG, "Load ImgConfiguration failed!");
-			return bRet;
-		}
-		else{
-			m_pHostApi->PicDebug(PIC_LOG_DEBUG, "Load ImgConfiguration succeeded while play local image!");
-			m_pHostApi->PicDebug(PIC_LOG_DEBUG, "m_stPlayConfig.strRootPath: %s", m_stPlayConfig.strRootPath);
-		}
-
-		m_stPlayConfig.nWndX = nWndX;
-		m_stPlayConfig.nWndY = nWndY;
-		m_stPlayConfig.nWndWidth = nWndWidth;
-		m_stPlayConfig.nWndHeight = nWndHeight;
-
-		rvc_picture_player_param_t tplayer_param = { 0 };
-		tplayer_param.icx = m_stPlayConfig.nWndX;
-		tplayer_param.icy = m_stPlayConfig.nWndY;
-		tplayer_param.uwindow_width = m_stPlayConfig.nWndWidth;
-		tplayer_param.uwindow_height = m_stPlayConfig.nWndHeight;
-
-		if (0 == GetPicturePlayingParams(&tplayer_param)) {
-			if (0 == m_Player->InitParam(&tplayer_param))
-			{
-				m_pHostApi->PicDebug(PIC_LOG_DEBUG, "init picture player Success.");
-				m_pHostApi->PicDebug(PIC_LOG_DEBUG, "start picture play success.");
-				m_PlayThread = (HANDLE)_beginthreadex(NULL, 0, &PicturePlayingFunc, m_Player, 0, NULL);
-				if (NULL != m_PlayThread) {
-					m_pHostApi->PicDebug(PIC_LOG_DEBUG, "create picture play thread success.");
-					m_bIsPlay = true;
-					bRet = true;
-					m_pHostApi->PicDebug(PIC_LOG_DEBUG, "start picture play success.");
-				}
-				else {
-					m_pHostApi->PicDebug(PIC_LOG_DEBUG, "create picture play thread failed.");
-				}
-			}
-		}
-		else {
-			m_pHostApi->PicDebug(PIC_LOG_DEBUG, "get picture playing params failed!");
-		}
-
-		return bRet;
-	}
-
-	bool StopPlay()
-	{
-		if (NULL != m_Player)
-		{
-			if (m_Player->GetPicPlayingFlag())
-			{
-				m_Player->StopPicPlay();
-				m_bIsPlay = false;
-			}
-			else
-			{
-				m_pHostApi->PicDebug(PIC_LOG_DEBUG, "picture playing already stopped!");
-			}
-		}
-		return true;
-	}
-
-	bool IsFileExist(const char* pFilePath)
-	{
-		bool bRet = false;
-		if (NULL != pFilePath) {
-			if (0 == _access(pFilePath, 0)) {
-				bRet = true;
-			}
-		}
-		return bRet;
-	}
-};
-
-Clibpictureplayer::Clibpictureplayer(CPicHostApi* pHostApi)
-{
-	m_pImpl = new libpictureplayer_impl(pHostApi);
-}
-
-Clibpictureplayer::~Clibpictureplayer()
-{
-	delete m_pImpl;
-	m_pImpl = NULL;
-}
-
-void Clibpictureplayer::Play(int nCfgInx, int nWndX, int nWndY, int nWndWidth, int nWndHeight)
-{
-	m_pImpl->StartPlay(nCfgInx, nWndX, nWndY, nWndWidth, nWndHeight);
-}
-
-void Clibpictureplayer::PlayMedia(CPicPlayConfig& config)
-{
-	m_pImpl->StartPlayMedia(config);
-}
-
-bool Clibpictureplayer::checkIsStop() {
-	return m_pImpl->isStop();
-}
-
-bool Clibpictureplayer::checkIsPlay(void* pthreadid)
-{
-	return m_pImpl->CheckIsPlay(pthreadid);
-}
-
-void Clibpictureplayer::Close()
-{
-	m_pImpl->StopPlay();
-}

+ 0 - 8
Other/win/libpictureplayer/stdafx.cpp

@@ -1,8 +0,0 @@
-// stdafx.cpp : source file that includes just the standard includes
-// libpictureplayer.pch will be the pre-compiled header
-// stdafx.obj will contain the pre-compiled type information
-
-#include "stdafx.h"
-
-// TODO: reference any additional headers you need in STDAFX.H
-// and not in this file

+ 0 - 16
Other/win/libpictureplayer/stdafx.h

@@ -1,16 +0,0 @@
-// stdafx.h : include file for standard system include files,
-// or project specific include files that are used frequently, but
-// are changed infrequently
-//
-
-#pragma once
-
-#include "targetver.h"
-
-#define WIN32_LEAN_AND_MEAN             // Exclude rarely-used stuff from Windows headers
-// Windows Header Files:
-#include <windows.h>
-
-
-
-// TODO: reference additional headers your program requires here

+ 0 - 8
Other/win/libpictureplayer/targetver.h

@@ -1,8 +0,0 @@
-#pragma once
-
-// Including SDKDDKVer.h defines the highest available Windows platform.
-
-// If you wish to build your application for a previous Windows platform, include WinSDKVer.h and
-// set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h.
-
-#include <SDKDDKVer.h>

+ 8 - 133
Other/win/libwmpplayer/libwmpplayer.cpp

@@ -123,75 +123,6 @@ public:
 		}
 	}
 
-	BOOL StartPlayVideo(const char *pVideoDir, const char *pNamePrefix = NULL, int nVideoCount = 1)
-	{
-		if (pVideoDir == NULL)
-			return FALSE;
-		if (m_bIsPlay)
-		{
-			if (m_pDlg != NULL)
-				return TRUE;
-		}
-		else
-		{
-			m_bIsPlay = TRUE;
-			//m_pHostApi->WmpDebug("StartPlayVideo set m_bIsPlay is TRUE.");
-		}
-		
-		strcpy(m_stPlayConfig.strRootPath, pVideoDir);
-
-		strcpy(m_stPlayConfig.strNamePrefix, "");
-		m_stPlayConfig.eMode = SINGLE;
-		
-		m_stPlayConfig.nFileCnt = nVideoCount;
-		m_stPlayConfig.bPrimMonitor = true;
-
-		return CreateWMPDialog();
-	}
-
-	BOOL StartPlaySalesRecordVideo(int nWndX, int nWndY, int nWndWidth, int nWndHeight, const char *pVideoDir, const char *pNamePrefix = NULL, int nVideoCount = 1)
-	{
-		if (pVideoDir == NULL) {
-			return FALSE;
-		}
-		
-		if (m_bIsPlay){
-			if (m_pDlg != NULL) {
-				return TRUE;
-			}
-		}
-		else{
-			m_bIsPlay = TRUE;
-			//m_pHostApi->WmpDebug("StartPlayVideo set m_bIsPlay is TRUE.");
-		}
-
-		//m_pHostApi->WmpDebug("nWndX=%d, nWndY=%d, nWndWidth=%d, nWndHeight=%d!", nWndX,nWndY,nWndWidth,nWndHeight);
-		BOOL bRet = m_pHostApi->LoadPlayConfig(m_stPlayConfig);
-		m_stPlayConfig.nWndX = nWndX;
-		m_stPlayConfig.nWndY = nWndY;
-		m_stPlayConfig.nWndWidth = nWndWidth;
-		m_stPlayConfig.nWndHeight = nWndHeight;
-		if (!bRet){
-			m_pHostApi->WmpDebug("Load WmpConfiguration failed while play local video!");
-			return FALSE;
-		}
-		else
-		{
-			//m_pHostApi->WmpDebug("Load WmpConfiguration succeeded while play local video!");
-			//m_pHostApi->WmpDebug("m_stPlayConfig.strRootPath: %s", m_stPlayConfig.strRootPath);
-		}
-
-		strcpy(m_stPlayConfig.strRootPath, pVideoDir);
-
-		strcpy(m_stPlayConfig.strNamePrefix, "");
-		m_stPlayConfig.eMode = SINGLE;
-
-		m_stPlayConfig.nFileCnt = nVideoCount;
-		m_stPlayConfig.bPrimMonitor = true;
-
-		return CreateWMPDialog();
-	}
-
 
 	BOOL StartPlayVideoNotice(int nWndX, int nWndY, int nWndWidth, int nWndHeight, const char *pVideoDir, const char *pVideoName)
 	{
@@ -293,50 +224,6 @@ public:
 		return CreateWMPDialog();
 	}
 
-	BOOL StartPlayLocalVideo(int nCfgInx, int nWndX, int nWndY, int nWndWidth, int nWndHeight)
-	{
-		if (m_bIsPlay)
-		{
-			if (m_pDlg != NULL)
-				return TRUE;
-		}
-		else
-			m_bIsPlay = TRUE;
-		
-		m_stPlayConfig.eMode = LOCALVIDEO;
-
-		//m_pHostApi->WmpDebug("nCfgInx=%d, nWndX=%d, nWndY=%d, nWndWidth=%d, nWndHeight=%d!", nCfgInx,nWndX,nWndY,nWndWidth,nWndHeight);
-		BOOL bRet = m_pHostApi->LoadPlayConfig(m_stPlayConfig, nCfgInx);
-		m_stPlayConfig.eMode = LOCALVIDEO;
-		m_stPlayConfig.nWndX = nWndX;
-		m_stPlayConfig.nWndY = nWndY;
-		m_stPlayConfig.nWndWidth = nWndWidth;
-		m_stPlayConfig.nWndHeight = nWndHeight;
-		if (!bRet)
-		{
-			m_pHostApi->WmpDebug("Load WmpConfiguration failed while play local video!");
-			return FALSE;
-		}
-		else
-		{
-			//m_pHostApi->WmpDebug("Load WmpConfiguration succeeded while play local video!");
-			//m_pHostApi->WmpDebug("m_stPlayConfig.strRootPath: %s", m_stPlayConfig.strRootPath);
-		}
-
-		// 判断当前时间是否允许播放
-		SYSTEMTIME st;
-		GetLocalTime(&st);
-		TCHAR strNow[TIME_LEN];
-		sprintf(strNow, "%02d:%02d:%02d", st.wHour,st.wMinute, st.wSecond);
-		if (strcmp(strNow, m_stPlayConfig.strVideoRunTime_S) < 0 || strcmp(strNow, m_stPlayConfig.strVideoRunTime_E) >= 0)
-		{
-			m_pHostApi->WmpDebug("Now is %s, play video rejected!", strNow);
-			return TRUE;
-		}
-
-		return CreateWMPDialog();
-	}
-
 
 	BOOL CreateWMPDialog()
 	{
@@ -459,52 +346,40 @@ Clibwmpplayer::~Clibwmpplayer()
 	m_pImpl = NULL;
 }
 
-VOID Clibwmpplayer::PlayVideo(const char *pVideoDir, const char *pNamePrefix, int nVideoCount)
-{
-	m_pImpl->StartPlayVideo(pVideoDir, pNamePrefix, nVideoCount);
-}
 
-VOID Clibwmpplayer::PlayLocalAudio(const char *pAudioNames)
+void Clibwmpplayer::PlayLocalAudio(const char *pAudioNames)
 {
 	m_pImpl->StartPlayLocalAudio(pAudioNames);
 }
 
-VOID Clibwmpplayer::PlayLocalVideo(int nCfgInx, int nWndX, int nWndY, int nWndWidth, int nWndHeight)
-{
-	m_pImpl->StartPlayLocalVideo(nCfgInx, nWndX, nWndY, nWndWidth, nWndHeight);
-}
 
-BOOL Clibwmpplayer::checkIsPlay(HANDLE &curThread)
+bool Clibwmpplayer::checkIsPlay(HANDLE &curThread)
 {
 	return m_pImpl->CheckIsPlay(curThread);
 }
 
-BOOL Clibwmpplayer::checkIsStop()
+bool Clibwmpplayer::checkIsStop()
 {
 	return m_pImpl->isStop();
 }
 
-VOID Clibwmpplayer::PlayMedia(CWmpPlayConfig &config)
+void Clibwmpplayer::PlayMedia(CWmpPlayConfig &config)
 {
 	m_pImpl->StartPlayMedia(config);
 }
 
-VOID Clibwmpplayer::Close()
+void Clibwmpplayer::Close()
 {
 	m_pImpl->StopPlay();
 }
 
-VOID Clibwmpplayer::SetVolume( int nVolume )
+void Clibwmpplayer::SetVolume( int nVolume )
 {
 	m_pImpl->SetVolume(nVolume);
 }
 
-VOID Clibwmpplayer::PlaySalesRecordVideo(int nWndX, int nWndY, int nWndWidth, int nWndHeight, const char *pVideoDir, const char *pNamePrefix, int nVideoCount)
-{
-	m_pImpl->StartPlaySalesRecordVideo(nWndX, nWndY, nWndWidth, nWndHeight, pVideoDir, pNamePrefix, nVideoCount);
-}
 
-VOID Clibwmpplayer::PlayVideoNotice(int nWndX, int nWndY, int nWndWidth, int nWndHeight, const char *pVideoDir, const char *pFileName)
+void Clibwmpplayer::PlayVideoNotice(int nWndX, int nWndY, int nWndWidth, int nWndHeight, const char *pVideoDir, const char *pFileName)
 {
-	m_pImpl->StartPlayVideoNotice(nWndX, nWndY, nWndWidth, nWndHeight, pVideoDir,pFileName);
+	m_pImpl->StartPlayVideoNotice(nWndX, nWndY, nWndWidth, nWndHeight, pVideoDir, pFileName);
 }

+ 9 - 15
Other/win/libwmpplayer/libwmpplayer.h

@@ -8,7 +8,7 @@
 
 #include <Windows.h>
 
-#define TIME_LEN      9
+#define TIME_LEN      16
 #define MAX_FILECOUNT 32
 
 
@@ -48,7 +48,7 @@ struct CWmpPlayConfig
 
 struct __declspec(novtable) CWmpHostApi
 {
-	virtual BOOL LoadPlayConfig(CWmpPlayConfig &config, int CfgInx = 0) = 0;
+	virtual bool LoadPlayConfig(CWmpPlayConfig &config, int CfgInx = 0) = 0;
 	virtual void WmpDebug(const char *fmt, ...) = 0;
 	virtual void WmpLogEvt(int ievent, const char* strmsg) = 0;
 };
@@ -61,25 +61,19 @@ public:
 	Clibwmpplayer(CWmpHostApi *pHostApi);
 	~Clibwmpplayer();
 
-	VOID PlayVideo(const char *pVideoDir, const char *pNamePrefix = NULL, int nVideoCount = 1);
+	void PlayLocalAudio(const char *pAudioNames);
 
-	VOID PlayLocalAudio(const char *pAudioNames);
+	void Close();
 
-	VOID PlayLocalVideo(int nCfgInx, int nWndX, int nWndY, int nWndWidth, int nWndHeight);
+	bool checkIsPlay(HANDLE &curThread);
 
-	VOID Close();
+	bool checkIsStop();
 
-	BOOL checkIsPlay(HANDLE &curThread);
+	void PlayMedia(CWmpPlayConfig &config);
 
-	BOOL checkIsStop();
+	void SetVolume(int nVolume);
 
-	VOID PlayMedia(CWmpPlayConfig &config);
-
-	VOID SetVolume(int nVolume);
-
-	VOID PlaySalesRecordVideo(int nWndX, int nWndY, int nWndWidth, int nWndHeight, const char *pVideoDir, const char *pNamePrefix = NULL, int nVideoCount = 1);
-
-	VOID PlayVideoNotice(int nWndX, int nWndY, int nWndWidth, int nWndHeight, const char *pVideoDir, const char *pFileName);
+	void PlayVideoNotice(int nWndX, int nWndY, int nWndWidth, int nWndHeight, const char *pVideoDir, const char *pFileName);
 private:
 	libwmpplayer_impl *m_pImpl;
 };

Some files were not shown because too many files changed in this diff