Skip to content

Commit

Permalink
添加声音
Browse files Browse the repository at this point in the history
  • Loading branch information
895377235 committed Apr 24, 2019
1 parent 5280e4e commit f86e129
Show file tree
Hide file tree
Showing 53 changed files with 854 additions and 59 deletions.
37 changes: 37 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# starrtc windows示例程序


![主界面](assets/主界面.png)

本产品完全免费,并且提供免费的私有部署服务端程序,支持全部功能,并提供第三方拉流、推流功能。

需要我们支持请加QQ群:807242783

如需私有部署,请到如下地址下载:

https://github.com/starrtc/starrtc-server


示例程序请运行release目录里面的starrtcdemo.exe

工程所在目录:starrtcdemo\starrtcdemo.sln
Expand All @@ -14,6 +26,31 @@
头文件 third\starrtccoredll
动态库 release\starrtc-demo

IM
====
![IM_一对一](assets/IM_一对一.png)

![聊天室](assets/聊天室.png)

VOIP视频通话
====
![VOIP](assets/VOIP.png)


多人会议
====
![多人会议](assets/多人会议.png)


互动直播
====
![互动直播](assets/互动直播.png)


监控
====
![监控](assets/监控.png)

Contact
=====
QQ : 2162498688
Expand Down
Binary file added assets/IM_一对一.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/VOIP.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/主界面.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/互动直播.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/多人会议.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/监控.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/聊天室.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified release/starrtc-demo/libstarRTC.dll
Binary file not shown.
3 changes: 1 addition & 2 deletions release/starrtc-demo/param.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
[param]
#userId不要填,会自动生成
userId=
userId=1022505
agentId=stargWeHN8Y7
loginServiceIP=ips2.starrtc.com
loginServicePort=9920
Expand Down
3 changes: 1 addition & 2 deletions release/starrtc-demo/param私有部署配置.ini
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
[param]
userId=
userId=1022505
agentId=stargWeHN8Y7
#将 your_ip 替换成你真实的ip地址
loginServiceIP=your_ip
loginServicePort=9920
msgServiceIP=your_ip
Expand Down
Binary file modified release/starrtc-demo/starrtc.exe
Binary file not shown.
Binary file modified release/starrtc-demo/starrtccoreDll.dll
Binary file not shown.
Binary file modified release/starrtc-demo/starrtcdemo.exe
Binary file not shown.
7 changes: 4 additions & 3 deletions starrtcdemo/starrtcdemo/CChatroomManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,9 @@ void CChatroomManager::getChatroomList(CUserManager* pUserManager, int listType)
}
else
{

StarRtcCore::getStarRtcCoreInstance(pUserManager)->queryAllChatRoomList((char*)pUserManager->m_ServiceParam.m_strChatServiceIP.c_str(), pUserManager->m_ServiceParam.m_nChatServicePort, listType);
char strListType[10] = { 0 };
sprintf_s(strListType, "%d", listType);
StarRtcCore::getStarRtcCoreInstance(pUserManager)->queryAllChatRoomList((char*)pUserManager->m_ServiceParam.m_strChatServiceIP.c_str(), pUserManager->m_ServiceParam.m_nChatServicePort, (char*)pUserManager->m_ServiceParam.m_strUserId.c_str(), strListType);
}

}
Expand Down Expand Up @@ -265,7 +266,7 @@ bool CChatroomManager::reportChatroom(string strRoomId, ChatroomInfo& chatroomIn
}
else
{
StarRtcCore::getStarRtcCoreInstance(m_pUserManager)->saveToChatRoomList((char*)m_pUserManager->m_ServiceParam.m_strChatServiceIP.c_str(), m_pUserManager->m_ServiceParam.m_nChatServicePort, listType, (char*)strRoomId.c_str(), chatroomInfo);
StarRtcCore::getStarRtcCoreInstance(m_pUserManager)->saveToChatRoomList((char*)m_pUserManager->m_ServiceParam.m_strChatServiceIP.c_str(), m_pUserManager->m_ServiceParam.m_nChatServicePort, (char*)m_pUserManager->m_ServiceParam.m_strUserId.c_str(), listType, (char*)strRoomId.c_str(), chatroomInfo);
}
return true;
}
Expand Down
7 changes: 6 additions & 1 deletion starrtcdemo/starrtcdemo/CChatroomManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,13 @@ class CChatroomManager : public IStarIMChatroomListener
bool sendChat(CIMMessage* pIMMessage);
bool sendPrivateChat(string toUserId, char* msgData);
bool sendChatroomPrivateControlMessage(string targetId, int code);
/*
* 删除聊天室
*/
bool deleteChatRoom();

/*
* 创建后上报创建的聊天室信息
*/
bool reportChatroom(string strRoomId, ChatroomInfo& chatroomInfo, int listType);

/*
Expand Down
10 changes: 9 additions & 1 deletion starrtcdemo/starrtcdemo/CCodecManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ CCodecManager::CCodecManager(CUserManager* pUserManager)
CCodecManager::~CCodecManager()
{
}

void CCodecManager::insertAudioRaw(uint8_t* audioData, int dataLen)
{
StarRtcCore::getStarRtcCoreInstance(m_pUserManager)->insertAudioRaw(audioData, dataLen);
}
//videoData的释放由此函数负责
void CCodecManager::insertVideoNalu(uint8_t* videoData, int dataLen)
{
Expand All @@ -28,3 +31,8 @@ int CCodecManager::cropVideoRawNV12(int w, int h, uint8_t* videoData, int dataLe
{
return StarRtcCore::getStarRtcCoreInstance(m_pUserManager)->cropVideoRawNV12(w, h, videoData, dataLen, yuvProcessPlan, rotation, needMirror, outVideoDataBig, outVideoDataSmall);
}

void CCodecManager::querySoundData(uint8_t** pData, int* nLength)
{
StarRtcCore::getStarRtcCoreInstance(m_pUserManager)->querySoundData(pData, nLength);
}
2 changes: 2 additions & 0 deletions starrtcdemo/starrtcdemo/CCodecManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ class CCodecManager
CCodecManager(CUserManager* pUserManager);
virtual ~CCodecManager();
public:
void insertAudioRaw(uint8_t* audioData, int dataLen);
//videoData的释放由此函数负责
void insertVideoNalu(uint8_t* videoData, int dataLen);
//videoData的释放由此函数负责
Expand All @@ -15,6 +16,7 @@ class CCodecManager
//videoData由在函数内释放
//成功返回0,失败返回-1
int cropVideoRawNV12(int w, int h, uint8_t* videoData, int dataLen, int yuvProcessPlan, int rotation, int needMirror, uint8_t* outVideoDataBig, uint8_t* outVideoDataSmall);
void querySoundData(uint8_t** pData, int* nLength);
public:
CUserManager* m_pUserManager;
};
Expand Down
Binary file modified starrtcdemo/starrtcdemo/CGroupDialog.cpp
Binary file not shown.
3 changes: 0 additions & 3 deletions starrtcdemo/starrtcdemo/CGroupManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ class CGroupManager : public IGroupListener
/**
* 创建群
* @param groupName
* @param callback
*/
bool createGroup(string groupName);

Expand Down Expand Up @@ -63,7 +62,6 @@ class CGroupManager : public IGroupListener
* @param groupID
* @param atUserIDs
* @param Message
* @param callback
* @return 发出的消息
*/
CIMMessage* sendMessage(string groupID, list<string> atUserIDs, string Message);
Expand All @@ -73,7 +71,6 @@ class CGroupManager : public IGroupListener
* @param groupID
* @param atUserIDs
* @param Message
* @param callback
* @return 发出的消息
*/
CIMMessage* sendOnlineMessage(string groupID, list<string> atUserIDs, string Message);
Expand Down
Binary file modified starrtcdemo/starrtcdemo/CInteracteLiveDlg.cpp
Binary file not shown.
Binary file modified starrtcdemo/starrtcdemo/CInteracteLiveDlg.h
Binary file not shown.
21 changes: 19 additions & 2 deletions starrtcdemo/starrtcdemo/CLiveManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ bool CLiveManager::createLiveAndJoin(string strName, int chatroomType, int chann
//join channe
pSrcManager->globalSetting(15, 1024);
bRet = pSrcManager->applyUpload();
pSrcManager->startEncoder();
pSrcManager->startEncoder(m_pUserManager->m_AudioParam.m_nSampleRateInHz, m_pUserManager->m_AudioParam.m_nChannels, m_pUserManager->m_AudioParam.m_nBitRate, 0);
if (length > 7)
{
length = 7;
Expand All @@ -67,6 +67,15 @@ bool CLiveManager::createLiveAndJoin(string strName, int chatroomType, int chann
return bRet;
}

void CLiveManager::insertAudioRaw(uint8_t* audioData, int dataLen)
{
if (m_pLiveInterface != NULL)
{
((CSrcManager*)m_pLiveInterface)->insertAudioRaw(audioData, dataLen);
}
}


void CLiveManager::insertVideoNalu(uint8_t* videoData, int dataLen)
{
if (m_pLiveInterface != NULL)
Expand Down Expand Up @@ -141,7 +150,7 @@ bool CLiveManager::joinLive(string strChatroomId, string strChannelId, bool bSel
pSrcManager->getChannelServerAddr();
pSrcManager->globalSetting(15, 1024);
bRet = pSrcManager->applyUpload();
pSrcManager->startEncoder();
pSrcManager->startEncoder(m_pUserManager->m_AudioParam.m_nSampleRateInHz, m_pUserManager->m_AudioParam.m_nChannels, m_pUserManager->m_AudioParam.m_nBitRate, 0);

}
else
Expand Down Expand Up @@ -256,6 +265,14 @@ void CLiveManager::commandToAudience(string toId)
m_pChatroomManager->sendChatroomPrivateControlMessage(toId, CONTROL_CODE_LIVE_LINK_STOP);
}
}

void CLiveManager::querySoundData(uint8_t** pData, int* nLength)
{
if (m_pLiveInterface != NULL)
{
m_pLiveInterface->querySoundData(pData, nLength);
}
}
/**
* 聊天室成员数变化
* @param number
Expand Down
3 changes: 2 additions & 1 deletion starrtcdemo/starrtcdemo/CLiveManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class CLiveManager: public IChatroomManagerListener, public ISrcManagerListener,
CLiveManager(CUserManager* pUserManager, ILiveListener* pLiveListener);
virtual ~CLiveManager();
bool createLiveAndJoin(string strName, int chatroomType, int channelType, int* streamConfig, int length);
void insertAudioRaw(uint8_t* audioData, int dataLen);
void insertVideoNalu(uint8_t* videoData, int dataLen);
void insertVideoRaw(uint8_t* videoData, int dataLen, int isBig);
int cropVideoRawNV12(int w, int h, uint8_t* videoData, int dataLen, int yuvProcessPlan, int rotation, int needMirror, uint8_t* outVideoDataBig, uint8_t* outVideoDataSmall);
Expand Down Expand Up @@ -55,7 +56,7 @@ class CLiveManager: public IChatroomManagerListener, public ISrcManagerListener,
void refuseInviteToBroadcaster(string toId);

void commandToAudience(string toId);

void querySoundData(uint8_t** pData, int* nLength);
public:
/**
* 聊天室成员数变化
Expand Down
30 changes: 13 additions & 17 deletions starrtcdemo/starrtcdemo/CLogin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ CLogin::CLogin(CUserManager* pUserManager)
m_pUserManager = pUserManager;
StarRtcCore::getStarRtcCoreInstance(m_pUserManager)->setLogFile("test");
StarRtcCore::getStarRtcCoreInstance(m_pUserManager)->setconfigLog(3, 31, 1);
//StarRtcCore::getStarRtcCoreInstance(m_pUserManager)->saveFile(1);
m_pUserManager->m_AudioParam.m_nSampleRateInHz = AUDIO_SAMPLE_RATE;
m_pUserManager->m_AudioParam.m_nChannels = AUDIO_CHANNELS;
m_pUserManager->m_AudioParam.m_nBitRate = AUDIO_BIT_RATE;
}


Expand Down Expand Up @@ -197,9 +201,6 @@ string CLogin::getServiceParam()
bool CLogin::logIn()
{
bool bRet = false;
//CHttpClient httpClient;
//CInternetSession temp;

if (m_pUserManager->m_bUserDispatch)
{
bRet = getAuthKey(m_pUserManager->m_ServiceParam.m_strUserId);
Expand All @@ -212,18 +213,20 @@ bool CLogin::logIn()
{
return bRet;
}

bRet = getIMServerAddr(m_pUserManager->m_ServiceParam.m_strUserId, m_pUserManager->m_ServiceParam.m_strAgentId);
if (bRet == false)
{
return bRet;
}
}
else
{
bRet = true;
m_pUserManager->m_strTokenId = "free";
m_pUserManager->m_strIMServerIp = m_pUserManager->m_ServiceParam.m_strMessageServiceIP;
m_pUserManager->m_nIMServerPort = m_pUserManager->m_ServiceParam.m_nMessageServicePort;
}
bRet = getIMServerAddr(m_pUserManager->m_ServiceParam.m_strUserId, m_pUserManager->m_ServiceParam.m_strAgentId);
if (bRet == false)
{
return bRet;
}

bRet = startIMServer((char*)m_pUserManager->m_strIMServerIp.c_str(), m_pUserManager->m_nIMServerPort, (char*)m_pUserManager->m_ServiceParam.m_strUserId.c_str(), (char*)m_pUserManager->m_ServiceParam.m_strAgentId.c_str(), (char*)m_pUserManager->m_strTokenId.c_str());
return bRet;
}
Expand Down Expand Up @@ -307,13 +310,6 @@ bool CLogin::getIMServerAddr(string userId, string agentId)
bool bRet = false;
m_pUserManager->m_strIMServerIp = "";
m_pUserManager->m_nIMServerPort = 0;
if (m_pUserManager->m_bUserDispatch == false)
{
m_pUserManager->m_strIMServerIp = m_pUserManager->m_ServiceParam.m_strMessageServiceIP;
m_pUserManager->m_nIMServerPort = m_pUserManager->m_ServiceParam.m_nMessageServicePort;
return true;
}

CString url = "";
url.Format(_T("http://%s:%d"), m_pUserManager->m_ServiceParam.m_strMessageServiceIP.c_str(), m_pUserManager->m_ServiceParam.m_nMessageServicePort);

Expand Down Expand Up @@ -355,7 +351,7 @@ bool CLogin::startIMServer(string strIP, int nPort, string userId, string agentI
return StarRtcCore::getStarRtcCoreInstance(m_pUserManager)->startIMServer((char*)strIP.c_str(), nPort, (char*)agentId.c_str(), (char*)userId.c_str(), (char*)strToken.c_str());
}
/*
* 开启IM服务
* 停止IM服务
*/
bool CLogin::stopIMServer()
{
Expand Down
19 changes: 16 additions & 3 deletions starrtcdemo/starrtcdemo/CMeetingManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ bool CMeetingManager::createAndJoin(string strName, int chatroomType, int channe
//join channel
m_pSrcManager->globalSetting(15, 1024);
bRet = m_pSrcManager->applyUpload();
m_pSrcManager->startEncoder();
m_pSrcManager->startEncoder(m_pUserManager->m_AudioParam.m_nSampleRateInHz, m_pUserManager->m_AudioParam.m_nChannels, m_pUserManager->m_AudioParam.m_nBitRate, 0);
if (length > 7)
{
length = 7;
Expand All @@ -132,7 +132,13 @@ bool CMeetingManager::createAndJoin(string strName, int chatroomType, int channe

return bRet;
}

void CMeetingManager::insertAudioRaw(uint8_t* audioData, int dataLen)
{
if (m_pSrcManager != NULL)
{
m_pSrcManager->insertAudioRaw(audioData, dataLen);
}
}
void CMeetingManager::insertVideoNalu(uint8_t* videoData, int dataLen)
{
if (m_pSrcManager != NULL)
Expand Down Expand Up @@ -237,7 +243,7 @@ bool CMeetingManager::join(string strChatroomId, string strChannelId, int* strea
m_pSrcManager->getChannelServerAddr();
m_pSrcManager->globalSetting(15, 1024);
bRet = m_pSrcManager->applyUpload();
m_pSrcManager->startEncoder();
m_pSrcManager->startEncoder(m_pUserManager->m_AudioParam.m_nSampleRateInHz, m_pUserManager->m_AudioParam.m_nChannels, m_pUserManager->m_AudioParam.m_nBitRate, 0);

if (length > 7)
{
Expand Down Expand Up @@ -349,6 +355,13 @@ void CMeetingManager::refuseInviteToBroadcaster(string toId)
}
}

void CMeetingManager::querySoundData(uint8_t** pData, int* nLength)
{
if (m_pSrcManager != NULL)
{
m_pSrcManager->querySoundData(pData, nLength);
}
}
/**
* 聊天室成员数变化
* @param number
Expand Down
2 changes: 2 additions & 0 deletions starrtcdemo/starrtcdemo/CMeetingManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class CMeetingManager: public IChatroomManagerListener, public ISrcManagerListen
static void addChatroomGetListListener(IChatroomGetListListener* pChatroomGetListListener);
static void getMeetingList(CUserManager* pUserManager);
bool createAndJoin(string strName, int chatroomType, int channelType, int* streamConfig, int length);
void insertAudioRaw(uint8_t* audioData, int dataLen);
void insertVideoNalu(uint8_t* videoData, int dataLen);
void insertVideoRaw(uint8_t* videoData, int dataLen, int isBig);
int cropVideoRawNV12(int w, int h, uint8_t* videoData, int dataLen, int yuvProcessPlan, int rotation, int needMirror, uint8_t* outVideoDataBig, uint8_t* outVideoDataSmall);
Expand Down Expand Up @@ -53,6 +54,7 @@ class CMeetingManager: public IChatroomManagerListener, public ISrcManagerListen
void agreeInviteToBroadcaster(string toId);

void refuseInviteToBroadcaster(string toId);
void querySoundData(uint8_t** pData, int* nLength);
public:
/**
* 聊天室成员数变化
Expand Down
Binary file modified starrtcdemo/starrtcdemo/CMultipleMeetingDialog.cpp
Binary file not shown.
Binary file modified starrtcdemo/starrtcdemo/CMultipleMeetingDialog.h
Binary file not shown.
Loading

0 comments on commit f86e129

Please sign in to comment.