Update MediaClient
This commit is contained in:
408
MediaClient/RtspTest/RtspTest.cpp
Normal file
408
MediaClient/RtspTest/RtspTest.cpp
Normal file
@@ -0,0 +1,408 @@
|
||||
/***************************************************************************************
|
||||
*
|
||||
* IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
*
|
||||
* By downloading, copying, installing or using the software you agree to this license.
|
||||
* If you do not agree to this license, do not download, install,
|
||||
* copy or use the software.
|
||||
*
|
||||
* Copyright (C) 2014-2024, Happytimesoft Corporation, all rights reserved.
|
||||
*
|
||||
* Redistribution and use in binary forms, with or without modification, are permitted.
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed
|
||||
* under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
||||
* CONDITIONS OF ANY KIND, either express or implied. See the License for the specific
|
||||
* language governing permissions and limitations under the License.
|
||||
*
|
||||
****************************************************************************************/
|
||||
|
||||
#include "sys_inc.h"
|
||||
#include "rtsp_cln.h"
|
||||
#include "hqueue.h"
|
||||
#include "http.h"
|
||||
#include "http_parse.h"
|
||||
|
||||
|
||||
/**********************************************************/
|
||||
HQUEUE * g_queue;
|
||||
|
||||
int g_flag = 0;
|
||||
pthread_t g_tid = 0;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int event;
|
||||
CRtspClient * rtsp;
|
||||
} EVENT_PARAMS;
|
||||
|
||||
/**********************************************************/
|
||||
|
||||
/**
|
||||
* @desc : rtsp notify callback
|
||||
*
|
||||
* @params :
|
||||
* event : event type
|
||||
* puser : user parameter
|
||||
*/
|
||||
int rtsp_notify_cb(int event, void * puser)
|
||||
{
|
||||
printf("%s, event = %d\r\n", __FUNCTION__, event);
|
||||
|
||||
CRtspClient * p_rtsp = (CRtspClient *) puser;
|
||||
|
||||
if (RTSP_EVE_CONNSUCC == event)
|
||||
{
|
||||
int vcodec = p_rtsp->video_codec();
|
||||
if (vcodec != VIDEO_CODEC_NONE)
|
||||
{
|
||||
char codec_str[20] = {'\0'};
|
||||
|
||||
switch (vcodec)
|
||||
{
|
||||
case VIDEO_CODEC_H264:
|
||||
strcpy(codec_str, "H264");
|
||||
break;
|
||||
|
||||
case VIDEO_CODEC_H265:
|
||||
strcpy(codec_str, "H265");
|
||||
break;
|
||||
|
||||
case VIDEO_CODEC_MP4:
|
||||
strcpy(codec_str, "MP4");
|
||||
break;
|
||||
|
||||
case VIDEO_CODEC_JPEG:
|
||||
strcpy(codec_str, "JPEG");
|
||||
break;
|
||||
}
|
||||
|
||||
printf("video codec is %s\r\n", codec_str);
|
||||
}
|
||||
|
||||
int acodec = p_rtsp->audio_codec();
|
||||
if (acodec != AUDIO_CODEC_NONE)
|
||||
{
|
||||
char codec_str[20] = {'\0'};
|
||||
|
||||
switch (acodec)
|
||||
{
|
||||
case AUDIO_CODEC_G711A:
|
||||
strcpy(codec_str, "G711A");
|
||||
break;
|
||||
|
||||
case AUDIO_CODEC_G711U:
|
||||
strcpy(codec_str, "G711U");
|
||||
break;
|
||||
|
||||
case AUDIO_CODEC_G722:
|
||||
strcpy(codec_str, "G722");
|
||||
break;
|
||||
|
||||
case AUDIO_CODEC_G726:
|
||||
strcpy(codec_str, "G726");
|
||||
break;
|
||||
|
||||
case AUDIO_CODEC_OPUS:
|
||||
strcpy(codec_str, "OPUS");
|
||||
break;
|
||||
|
||||
case AUDIO_CODEC_AAC:
|
||||
strcpy(codec_str, "AAC");
|
||||
break;
|
||||
}
|
||||
|
||||
printf("audio codec is %s\r\n", codec_str);
|
||||
printf("audio sample rate is %d\r\n", p_rtsp->get_audio_samplerate());
|
||||
printf("audio channels is %d\r\n", p_rtsp->get_audio_channels());
|
||||
}
|
||||
}
|
||||
|
||||
EVENT_PARAMS params;
|
||||
|
||||
params.event = event;
|
||||
params.rtsp = p_rtsp;
|
||||
|
||||
if (!hqBufPut(g_queue, (char *) ¶ms))
|
||||
{
|
||||
printf("hqBufPut failed\r\n");
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @desc : rtsp audio data callback
|
||||
*
|
||||
* @params :
|
||||
* pdata : audio data buffer
|
||||
* len : audio data buffer length
|
||||
* ts : timestamp
|
||||
* seq : sequential
|
||||
* puser : user parameter
|
||||
*/
|
||||
int rtsp_audio_cb(uint8 * pdata, int len, uint32 ts, uint16 seq, void * puser)
|
||||
{
|
||||
CRtspClient * p_rtsp = (CRtspClient *) puser;
|
||||
|
||||
printf("%s, len = %d, ts = %u, seq = %d\r\n", __FUNCTION__, len, ts, seq);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @desc : rtsp video data callback
|
||||
*
|
||||
* @params :
|
||||
* pdata : video data buffer
|
||||
* len : video data buffer length
|
||||
* ts : timestamp
|
||||
* seq : sequential
|
||||
* puser : user parameter
|
||||
*/
|
||||
int rtsp_video_cb(uint8 * pdata, int len, uint32 ts, uint16 seq, void * puser)
|
||||
{
|
||||
CRtspClient * p_rtsp = (CRtspClient *) puser;
|
||||
|
||||
printf("%s, len = %d, ts = %u, seq = %d\r\n", __FUNCTION__, len, ts, seq);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @desc : RTCP raw data callback
|
||||
*
|
||||
* @params :
|
||||
* pdata : RTCP raw data
|
||||
* len : data length
|
||||
* type : AV_VIDEO_CH, AV_AUDIO_CH, AV_METADATA_CH, AV_BACK_CH
|
||||
* puser : user parameter
|
||||
*/
|
||||
int rtsp_rtcp_cb(uint8 * pdata, int len, int type, void * puser)
|
||||
{
|
||||
CRtspClient * p_rtsp = (CRtspClient *) puser;
|
||||
|
||||
printf("%s, len = %d, type = %d\r\n", __FUNCTION__, len, type);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @desc : rtsp meta data callback
|
||||
*
|
||||
* @params :
|
||||
* pdata : meta data buffer
|
||||
* len : meta data buffer length
|
||||
* ts : timestamp
|
||||
* seq : sequential
|
||||
* puser : user parameter
|
||||
*/
|
||||
int rtsp_metadata_cb(uint8 * pdata, int len, uint32 ts, uint16 seq, void * puser)
|
||||
{
|
||||
CRtspClient * p_rtsp = (CRtspClient *) puser;
|
||||
|
||||
printf("%s, len = %d, ts = %u, seq = %d\r\n", __FUNCTION__, len, ts, seq);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void rtsp_setup(CRtspClient * p_rtsp)
|
||||
{
|
||||
p_rtsp->set_notify_cb(rtsp_notify_cb, p_rtsp);
|
||||
p_rtsp->set_audio_cb(rtsp_audio_cb);
|
||||
p_rtsp->set_video_cb(rtsp_video_cb);
|
||||
p_rtsp->set_rtcp_cb(rtsp_rtcp_cb);
|
||||
#ifdef METADATA
|
||||
p_rtsp->set_metadata_cb(rtsp_metadata_cb);
|
||||
#endif
|
||||
// p_rtsp->set_rtp_over_udp(1); // rtp over udp
|
||||
// p_rtsp->set_rtp_multicast(1); // force multicast rtp via rtsp
|
||||
#ifdef BACKCHANNEL
|
||||
// p_rtsp->set_bc_flag(1); // enable audio backchannel
|
||||
// p_rtsp->set_bc_data_flag(1); // enable send audio data
|
||||
#endif
|
||||
#ifdef REPLAY
|
||||
// p_rtsp->set_replay_flag(1); // enable replay
|
||||
// p_rtsp->set_replay_range(time(NULL) - 3600, time(NULL)); // set the replay timestamp range
|
||||
#endif
|
||||
#ifdef OVER_HTTP
|
||||
// p_rtsp->set_rtsp_over_http(1, 80); // rtsp over http
|
||||
#endif
|
||||
#ifdef OVER_WEBSOCKET
|
||||
// p_rtsp->set_rtsp_over_ws(1, 80); // rtsp over websocket
|
||||
#endif
|
||||
|
||||
p_rtsp->set_rx_timeout(10); // No data within 10s, receiving timeout
|
||||
// p_rtsp->set_channel(AV_VIDEO_CH, 0); // not setup video channel
|
||||
// p_rtsp->set_channel(AV_AUDIO_CH, 0); // not setup audio channel
|
||||
// p_rtsp->set_channel(AV_METADATA_CH, 0); // not setup metadata channel
|
||||
// p_rtsp->set_channel(AV_BACK_CH, 0); // not setup audio back channel
|
||||
}
|
||||
|
||||
void rtsp_reconn(CRtspClient * p_rtsp)
|
||||
{
|
||||
char url[256], user[64], pass[64];
|
||||
|
||||
strcpy(url, p_rtsp->get_url());
|
||||
strcpy(user, p_rtsp->get_user());
|
||||
strcpy(pass, p_rtsp->get_pass());
|
||||
|
||||
printf("rtsp_reconn, url = %s, user = %s, pass = %s\r\n", url, user, pass);
|
||||
|
||||
p_rtsp->rtsp_close();
|
||||
|
||||
rtsp_setup(p_rtsp);
|
||||
|
||||
p_rtsp->rtsp_start(url, user, pass);
|
||||
}
|
||||
|
||||
void * rtsp_notify_handler(void * argv)
|
||||
{
|
||||
EVENT_PARAMS params;
|
||||
|
||||
while (g_flag)
|
||||
{
|
||||
if (hqBufGet(g_queue, (char *) ¶ms))
|
||||
{
|
||||
if (params.event == -1 || params.rtsp == NULL)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
if (RTSP_EVE_STOPPED == params.event ||
|
||||
RTSP_EVE_CONNFAIL == params.event ||
|
||||
RTSP_EVE_NOSIGNAL == params.event ||
|
||||
RTSP_EVE_NODATA == params.event)
|
||||
{
|
||||
rtsp_reconn(params.rtsp);
|
||||
|
||||
usleep(100*1000);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
g_tid = 0;
|
||||
|
||||
printf("%s exit\r\n", __FUNCTION__);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#define RTSP_CLN_NUM 1
|
||||
|
||||
int main(int argc, char * argv[])
|
||||
{
|
||||
/*if (argc < 2)
|
||||
{
|
||||
printf("usage: %s url {user} {pass}\r\n", argv[0]);
|
||||
return -1;
|
||||
}*/
|
||||
|
||||
log_init("rtsptest.log");
|
||||
log_set_level(HT_LOG_DBG);
|
||||
|
||||
network_init();
|
||||
|
||||
// allocate system BUFFER and rtsp parser BUFFER
|
||||
sys_buf_init(RTSP_CLN_NUM * 8);
|
||||
rtsp_parse_buf_init(RTSP_CLN_NUM * 8);
|
||||
|
||||
#if defined(OVER_HTTP) || defined(OVER_WEBSOCKET)
|
||||
// allocate http message parser BUFFER
|
||||
http_msg_buf_init(RTSP_CLN_NUM * 8);
|
||||
#endif
|
||||
|
||||
// create event queue
|
||||
g_queue = hqCreate(RTSP_CLN_NUM * 4, sizeof(EVENT_PARAMS), HQ_PUT_WAIT | HQ_GET_WAIT);
|
||||
if (NULL == g_queue)
|
||||
{
|
||||
printf("create queue failed\r\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
// create event handler thread
|
||||
g_flag = 1;
|
||||
g_tid = sys_os_create_thread((void *)rtsp_notify_handler, NULL);
|
||||
if (g_tid == 0)
|
||||
{
|
||||
printf("create rtsp notify handler thread failed\r\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
CRtspClient * rtsp = new CRtspClient[RTSP_CLN_NUM];
|
||||
|
||||
for (int i = 0; i < RTSP_CLN_NUM; i++)
|
||||
{
|
||||
rtsp_setup(&rtsp[i]);
|
||||
|
||||
char * p_user = NULL;
|
||||
char * p_pass = NULL;
|
||||
|
||||
/*if (argc >= 3)
|
||||
{
|
||||
p_user = argv[2];
|
||||
}
|
||||
|
||||
if (argc >= 4)
|
||||
{
|
||||
p_pass = argv[3];
|
||||
}*/
|
||||
|
||||
BOOL ret = rtsp[i].rtsp_start("rtsp://118.70.125.152:5656/cam/realmonitor?channel=1&subtype=0", "root", "abcd1234");
|
||||
|
||||
printf("rtsp %d start ret = %d\r\n", i, ret);
|
||||
|
||||
usleep(100 * 1000);
|
||||
}
|
||||
|
||||
for (;;)
|
||||
{
|
||||
if (getchar() == 'q')
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
usleep(1000*1000); // 1s
|
||||
}
|
||||
|
||||
for (int i = 0; i < RTSP_CLN_NUM; i++)
|
||||
{
|
||||
rtsp[i].rtsp_close();
|
||||
}
|
||||
|
||||
delete[] rtsp;
|
||||
|
||||
g_flag = 0;
|
||||
|
||||
EVENT_PARAMS params;
|
||||
|
||||
params.event = -1;
|
||||
params.rtsp = NULL;
|
||||
|
||||
hqBufPut(g_queue, (char *) ¶ms);
|
||||
|
||||
// waiting for event handler thread to exit
|
||||
while (g_tid)
|
||||
{
|
||||
usleep(10*1000);
|
||||
}
|
||||
|
||||
hqDelete(g_queue);
|
||||
g_queue = NULL;
|
||||
|
||||
// free memory resources
|
||||
rtsp_parse_buf_deinit();
|
||||
sys_buf_deinit();
|
||||
|
||||
#if defined(OVER_HTTP) || defined(OVER_WEBSOCKET)
|
||||
http_msg_buf_deinit();
|
||||
#endif
|
||||
|
||||
// close log
|
||||
log_close();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
174
MediaClient/RtspTest/RtspTest.vcxproj
Normal file
174
MediaClient/RtspTest/RtspTest.vcxproj
Normal file
@@ -0,0 +1,174 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="RtspTest.cpp" />
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{79A3B043-27AD-491F-96D9-A4E0158ED10B}</ProjectGuid>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<RootNamespace>RtspTest</RootNamespace>
|
||||
<ProjectName>RtspTest</ProjectName>
|
||||
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
<OutDir>$(SolutionDir)$(Platform)\$(Configuration)\</OutDir>
|
||||
<TargetName>$(ProjectName)</TargetName>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
<OutDir>$(SolutionDir)$(Platform)\$(Configuration)\</OutDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<OutDir>$(SolutionDir)$(Platform)\$(Configuration)\</OutDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<OutDir>$(SolutionDir)$(Platform)\$(Configuration)\</OutDir>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>_DEBUG;_CONSOLE;HT_STATIC;METADATA;REPLAY;OVER_HTTP;OVER_WEBSOCKET;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>..\MediaClient;..\MediaClient\bm;..\MediaClient\http;..\MediaClient\rtsp;..\MediaClient\rtp;..\MediaClient\media;..\MediaClient\openssl\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<DisableSpecificWarnings>4996</DisableSpecificWarnings>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalLibraryDirectories>..\MediaClient\openssl\lib\x86;$(SolutionDir)$(Platform)\$(Configuration)\;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<AdditionalDependencies>RtspClientLibrary.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<OutputFile>$(OutDir)\$(ProjectName).exe</OutputFile>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>_DEBUG;_CONSOLE;HT_STATIC;METADATA;REPLAY;OVER_HTTP;OVER_WEBSOCKET;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>..\MediaClient;..\MediaClient\bm;..\MediaClient\http;..\MediaClient\rtsp;..\MediaClient\rtp;..\MediaClient\media;..\MediaClient\openssl\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<DisableSpecificWarnings>4996</DisableSpecificWarnings>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalLibraryDirectories>..\MediaClient\openssl\lib\x64;$(SolutionDir)$(Platform)\$(Configuration)\;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<AdditionalDependencies>RtspClientLibrary.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<OutputFile>$(OutDir)\$(ProjectName).exe</OutputFile>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>_DEBUG;_CONSOLE;HT_STATIC;METADATA;REPLAY;OVER_HTTP;OVER_WEBSOCKET;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>..\MediaClient;..\MediaClient\bm;..\MediaClient\http;..\MediaClient\rtsp;..\MediaClient\rtp;..\MediaClient\media;..\MediaClient\openssl\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<DisableSpecificWarnings>4996</DisableSpecificWarnings>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<AdditionalLibraryDirectories>..\MediaClient\openssl\lib\x86;$(SolutionDir)$(Platform)\$(Configuration)\;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<AdditionalDependencies>RtspClientLibrary.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<OutputFile>$(OutDir)\$(ProjectName).exe</OutputFile>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>_DEBUG;_CONSOLE;HT_STATIC;METADATA;REPLAY;OVER_HTTP;OVER_WEBSOCKET;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>..\MediaClient;..\MediaClient\bm;..\MediaClient\http;..\MediaClient\rtsp;..\MediaClient\rtp;..\MediaClient\media;..\MediaClient\openssl\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<DisableSpecificWarnings>4996</DisableSpecificWarnings>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<AdditionalLibraryDirectories>..\MediaClient\openssl\lib\x64;$(SolutionDir)$(Platform)\$(Configuration)\;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<AdditionalDependencies>RtspClientLibrary.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<OutputFile>$(OutDir)\$(ProjectName).exe</OutputFile>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
79
MediaClient/RtspTest/mac.mk
Normal file
79
MediaClient/RtspTest/mac.mk
Normal file
@@ -0,0 +1,79 @@
|
||||
################OPTION###################
|
||||
OUTPUT = rtsptest
|
||||
CCOMPILE = gcc
|
||||
CPPCOMPILE = g++
|
||||
COMPILEOPTION += -g -c -Wall
|
||||
COMPILEOPTION += -DIOS
|
||||
COMPILEOPTION += -DMETADATA
|
||||
COMPILEOPTION += -DREPLAY
|
||||
COMPILEOPTION += -DOVER_HTTP
|
||||
COMPILEOPTION += -DOVER_WEBSOCKET
|
||||
LINK = g++
|
||||
LINKOPTION = -g -o $(OUTPUT)
|
||||
INCLUDEDIR += -I../MediaClient
|
||||
INCLUDEDIR += -I../MediaClient/bm
|
||||
INCLUDEDIR += -I../MediaClient/http
|
||||
INCLUDEDIR += -I../MediaClient/media
|
||||
INCLUDEDIR += -I../MediaClient/rtp
|
||||
INCLUDEDIR += -I../MediaClient/rtsp
|
||||
INCLUDEDIR += -I../MediaClient/ffmpeg/include
|
||||
INCLUDEDIR += -I../MediaClient/openssl/include
|
||||
LIBDIRS += -L../MediaClient
|
||||
LIBDIRS += -L../MediaClient/ffmpeg/lib/linux
|
||||
LIBDIRS += -L../MediaClient/openssl/lib/linux
|
||||
|
||||
OBJS = RtspTest.o
|
||||
|
||||
ifneq ($(findstring BACKCHANNEL, $(COMPILEOPTION)),)
|
||||
SHAREDLIB += -lasound
|
||||
SHAREDLIB += -lavformat
|
||||
SHAREDLIB += -lswscale
|
||||
SHAREDLIB += -lavcodec
|
||||
SHAREDLIB += -lswresample
|
||||
SHAREDLIB += -lavutil
|
||||
SHAREDLIB += -lopus
|
||||
SHAREDLIB += -lx264
|
||||
SHAREDLIB += -lx265
|
||||
endif
|
||||
|
||||
ifneq ($(findstring HTTPS, $(COMPILEOPTION)),)
|
||||
SHAREDLIB += -lcrypto
|
||||
SHAREDLIB += -lssl
|
||||
endif
|
||||
|
||||
SHAREDLIB += -lrtspclient
|
||||
SHAREDLIB += -lpthread
|
||||
|
||||
APPENDLIB =
|
||||
|
||||
################OPTION END################
|
||||
|
||||
$(OUTPUT):$(OBJS) $(APPENDLIB)
|
||||
$(LINK) $(LINKOPTION) $(LIBDIRS) $(OBJS) $(SHAREDLIB) $(APPENDLIB)
|
||||
|
||||
clean:
|
||||
rm -f $(OBJS)
|
||||
rm -f $(OUTPUT)
|
||||
all: clean $(OUTPUT)
|
||||
.PRECIOUS:%.cpp %.cc %.cxx %.c %.m %.mm
|
||||
.SUFFIXES:
|
||||
.SUFFIXES: .cpp .cc .cxx .c .m .mm .o
|
||||
|
||||
.cpp.o:
|
||||
$(CPPCOMPILE) -c -o $*.o $(COMPILEOPTION) $(INCLUDEDIR) $*.cpp
|
||||
|
||||
.cc.o:
|
||||
$(CCOMPILE) -c -o $*.o $(COMPILEOPTION) $(INCLUDEDIR) $*.cc
|
||||
|
||||
.cxx.o:
|
||||
$(CPPCOMPILE) -c -o $*.o $(COMPILEOPTION) $(INCLUDEDIR) $*.cxx
|
||||
|
||||
.c.o:
|
||||
$(CCOMPILE) -c -o $*.o $(COMPILEOPTION) $(INCLUDEDIR) $*.c
|
||||
|
||||
.m.o:
|
||||
$(CCOMPILE) -c -o $*.o $(COMPILEOPTION) $(INCLUDEDIR) $*.m
|
||||
|
||||
.mm.o:
|
||||
$(CPPCOMPILE) -c -o $*.o $(COMPILEOPTION) $(INCLUDEDIR) $*.mm
|
||||
|
||||
128
MediaClient/RtspTest/rtsptest-1.log
Normal file
128
MediaClient/RtspTest/rtsptest-1.log
Normal file
@@ -0,0 +1,128 @@
|
||||
[2024-04-29 01:04:20] : [INFO] net_buf_init, num = 8
|
||||
|
||||
[2024-04-29 01:04:20] : [INFO] hdrv_buf_init, num = 64
|
||||
|
||||
[2024-04-29 01:04:20] : [DEBUG] TX >> OPTIONS rtsp://118.70.125.152:5656/cam/realmonitor?channel=1&subtype=0 RTSP/1.0
|
||||
|
||||
CSeq: 1
|
||||
|
||||
User-Agent: happytimesoft rtsp client
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
[2024-04-29 01:04:20] : [DEBUG] RX << RTSP/1.0 401 Unauthorized
|
||||
|
||||
CSeq: 1
|
||||
|
||||
WWW-Authenticate: Digest realm="Login to 77373879BF7156D2",nonce="9559d9f7-821e-4c8d-bd49-2babcb8b9ec0"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
[2024-04-29 01:04:20] : [DEBUG] TX >> OPTIONS rtsp://118.70.125.152:5656/cam/realmonitor?channel=1&subtype=0 RTSP/1.0
|
||||
|
||||
CSeq: 2
|
||||
|
||||
Authorization: Digest username="root", realm="Login to 77373879BF7156D2", nonce="9559d9f7-821e-4c8d-bd49-2babcb8b9ec0", uri="rtsp://118.70.125.152:5656/cam/realmonitor?channel=1&subtype=0", response="f8c01e1f767492c99554aec03a339983"
|
||||
|
||||
User-Agent: happytimesoft rtsp client
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
[2024-04-29 01:04:21] : [DEBUG] RX << RTSP/1.0 200 OK
|
||||
|
||||
CSeq: 2
|
||||
|
||||
Public: OPTIONS, DESCRIBE, ANNOUNCE, SETUP, PLAY, PAUSE, TEARDOWN, GET_PARAMETER, SET_PARAMETER, REDIRECT, RECORD
|
||||
|
||||
Server: Rtsp Server/3.0
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
[2024-04-29 01:04:21] : [DEBUG] TX >> DESCRIBE rtsp://118.70.125.152:5656/cam/realmonitor?channel=1&subtype=0 RTSP/1.0
|
||||
|
||||
CSeq: 3
|
||||
|
||||
Authorization: Digest username="root", realm="Login to 77373879BF7156D2", nonce="9559d9f7-821e-4c8d-bd49-2babcb8b9ec0", uri="rtsp://118.70.125.152:5656/cam/realmonitor?channel=1&subtype=0", response="e88e7221d817a8510a7fcbaa81ba0e2c"
|
||||
|
||||
Accept: application/sdp
|
||||
|
||||
User-Agent: happytimesoft rtsp client
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
[2024-04-29 01:04:21] : [DEBUG] RX << RTSP/1.0 200 OK
|
||||
|
||||
CSeq: 3
|
||||
|
||||
Content-Base: rtsp://118.70.125.152:5656/cam/realmonitor?channel=1&subtype=0/
|
||||
|
||||
Content-Type: application/sdp
|
||||
|
||||
x-Accept-Dynamic-Rate: 1
|
||||
|
||||
Cache-Control: must-revalidate
|
||||
|
||||
Content-Length: 473
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
[2024-04-29 01:04:21] : [DEBUG] v=0
|
||||
|
||||
o=- 2229913047 2229913047 IN IP4 0.0.0.0
|
||||
|
||||
s=Media Server
|
||||
|
||||
c=IN IP4 0.0.0.0
|
||||
|
||||
t=0 0
|
||||
|
||||
a=control:*
|
||||
|
||||
a=packetization-supported:DH
|
||||
|
||||
a=rtppayload-supported:DH
|
||||
|
||||
a=range:npt=now-
|
||||
|
||||
m=video 0 RTP/AVP 96
|
||||
|
||||
a=control:trackID=0
|
||||
|
||||
a=framerate:15.000000
|
||||
|
||||
a=rtpmap:96 H264/90000
|
||||
|
||||
a=fmtp:96 packetization-mode=1;profile-level-id=4D0029;sprop-parameter-sets=Z00AKYqKUBQAWtNEAAAPoAAB1MAQAA==,aO48gAA=
|
||||
|
||||
a=recvonly
|
||||
|
||||
m=audio 0 RTP/AVP 8
|
||||
|
||||
a=control:trackID=1
|
||||
|
||||
a=rtpmap:8 PCMA/8000
|
||||
|
||||
a=recvonly
|
||||
|
||||
|
||||
|
||||
[2024-04-29 01:04:21] : [DEBUG] TX >> SETUP rtsp://118.70.125.152:5656/cam/realmonitor?channel=1&subtype=0/trackID=0 RTSP/1.0
|
||||
|
||||
CSeq: 4
|
||||
|
||||
Authorization: Digest username="root", realm="Login to 77373879BF7156D2", nonce="9559d9f7-821e-4c8d-bd49-2babcb8b9ec0", uri="rtsp://118.70.125.152:5656/cam/realmonitor?channel=1&subtype=0", response="ab48f35df2194fe87175383bfd467921"
|
||||
|
||||
Transport: RTP/AVP/TCP;unicast;interleaved=0-1
|
||||
|
||||
15
MediaClient/RtspTest/stdafx.h
Normal file
15
MediaClient/RtspTest/stdafx.h
Normal file
@@ -0,0 +1,15 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <ws2tcpip.h>
|
||||
#include <ws2ipdef.h>
|
||||
#include <winsock2.h>
|
||||
#include <mmsystem.h>
|
||||
|
||||
#include <io.h>
|
||||
#include <iphlpapi.h>
|
||||
#include <vfw.h>
|
||||
|
||||
#include <tchar.h>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user