#include <stdlib.h>
|
#include <stdio.h>
|
#include <unistd.h>
|
#include <time.h>
|
|
#if __USE_RTSPCLIENT__
|
#include "RtspClient.h"
|
#else
|
#include "librtsp.h"
|
#endif
|
|
|
void StreamCallBack(int datatype, int frametype, unsigned char *data, unsigned int datalen, long userdata)
|
{
|
#if 0
|
printf("userdata:%ld,datatype:%d, frametype:%d, datalen:%d\n", userdata, datatype, frametype, datalen);
|
|
static FILE* fp_write = NULL;
|
if (!fp_write)
|
{
|
fp_write = fopen("stream_callback.mp4", "wb+");
|
}
|
fwrite(data, sizeof(char), datalen, fp_write);
|
#endif
|
}
|
|
|
int main(int argc, char *argv[])
|
{
|
#if __USE_RTSPCLIENT__
|
CRtspClient *rtsp_client = new CRtspClient();
|
//if (rtsp_client != NULL)
|
{
|
long userdata = 1001;
|
rtsp_client->OpenRtspStream("rtsp://192.168.12.122:9554/DevAor=11010100001320012122/StreamType=1/PlayType=1/BeginTime=2018-03-26T00:00:00/EndTime=2018-03-26T10:00:00/", StreamCallBack, userdata);
|
sleep(10);
|
rtsp_client->StopRtspStream();
|
}
|
#else
|
char test_rtspurl1[] = "rtsp://192.168.20.10:7554/DevAor=34020000001320000001";
|
char test_rtspurl2[] = "rtsp://172.17.50.245:7554/DevAor=11010870111320125141";
|
char test_rtspurl3[] = "rtsp://172.17.50.245:7554/DevAor=11010870111320125151";
|
char test_rtspurl4[] = "rtsp://172.17.50.245:7554/DevAor=11010870111320125152";
|
char test_rtspurl5[] = "rtsp://172.17.50.245:7554/DevAor=11010870111320125153";
|
char test_rtspurl6[] = "rtsp://172.17.50.245:7554/DevAor=11010870111320125155";
|
char test_rtspurl7[] = "rtsp://172.17.50.245:7554/DevAor=11010870111320125162";
|
// for test
|
//while (1)
|
{
|
long video_userdata = 1000;
|
printf("start.>>>>>>>>>>>>>>>>>>>>\n");
|
time_t start = time(NULL);
|
long video_handle = RTSPSTREAM_Open(test_rtspurl1, StreamCallBack, video_userdata);
|
time_t end = time(NULL);
|
printf("time :%ld\n", end - start);
|
printf("1.>>>>>>>>>>>>>>>>>>>>video_handle:%ld\n", video_handle);
|
if (video_handle < 0) {
|
return 1;
|
}
|
|
while(1){
|
sleep(5);
|
}
|
RTSPSTREAM_Close(video_handle);
|
}
|
sleep(1000);
|
return 0;
|
|
if (argc < 2)
|
{
|
printf("please write rtsp url!!!!!!!!\n");
|
return -1;
|
}
|
long userdata = 1001;
|
long handle = -1;
|
while (1)
|
{
|
handle = RTSPSTREAM_Open(argv[1], StreamCallBack, userdata);
|
|
sleep(5);
|
RTSPSTREAM_Close(handle);
|
sleep(5);
|
}
|
//µã²¥¿ØÖÆ
|
if (argc >= 3)
|
{
|
sleep(5);
|
//µã²¥²¥·Å¿ØÖÆ
|
RTSPSTREAM_Contrl(handle, HIS_VIDEO_CTRL_PAUSE, 0);
|
sleep(5);
|
//µã²¥²¥·Å¿ØÖÆ
|
RTSPSTREAM_Contrl(handle, HIS_VIDEO_CTRL_PLAY, 0);
|
sleep(5);
|
//µã²¥Âý·Å¿ØÖÆ
|
RTSPSTREAM_Contrl(handle, HIS_VIDEO_CTRL_SLOW, 4);
|
sleep(5);
|
//µã²¥¿ì·Å¿ØÖÆ
|
RTSPSTREAM_Contrl(handle, HIS_VIDEO_CTRL_FAST, 4);
|
sleep(5);
|
//µã²¥Ìø×ª¿ØÖÆ
|
RTSPSTREAM_Contrl(handle, HIS_VIDEO_CTRL_JUMP, 600);
|
}
|
|
|
#endif
|
return 0;
|
}
|
|
|
|