//使用方法:启动线程
HANDLE hThread1 = (HANDLE)_beginthreadex(NULL, 0, ThreadStreamFuc, NULL, 0, NULL);
if( hThread1 != NULL )
{
CloseHandle(hThread1);
}
unsigned __stdcall ThreadStreamFuc( PVOID pvParm )
{
//
/* :sout-all :sout-keep这两个参数不能带,带了会解码失败*/
//
//sout="#transcode{vcodec=theo,vb=800,acodec=vorb,ab=128,channels=2,samplerate=44100}:http{mux=ogg,dst=:8080/stream} :sout-all :sout-keep";
//
//
/*
//
cvlc -vvv rtsp://admin:
[email protected]:554/MPEG-4/ch1/main/av_stream
//
--sout "#transcode{vcodec=theo,vb=800,fps=25,scale=1,acodec=h264,ab=128,channels=2,samplerate=44100}:http{mux=ogg,dst=:10001/stream}"
//
--sout-keep
//
*/
//
//
//sout="#transcode{vcodec=h264,acodec=mpga,ab=128,channels=2,samplerate=44100}:file{dst=e:\\\\my.mp4,no-overwrite}";
//
//Screen Capture
//
//url = "screen://";
//取RTP H264视频流转为OGG推送到HTTP。
const char *sout="#transcode{vcodec=theo,vb=800,acodec=vorb,ab=128,channels=2,samplerate=44100}:http{mux=ogg,dst=:8080/stream}";
if (url == NULL)
{
url = "E:\\dfb_work\\VS2008\\FFMPEGTEST\\Debug\\my110.h264";//从文件取流
url = "rtp://@10.3.241.53:5004";//从RTP取流。//
url = "rtp://@239.1.1.1:5004";
url = "rtp_ps.sdp";//RDP需要的SDP文件
}
const char *media_name = url;
vlc = libvlc_new(0, NULL);
libvlc_vlm_add_broadcast(vlc, media_name, url, sout, 0, NULL, true, false);
libvlc_vlm_play_media(vlc, media_name);
cout<<"\nvlc play media loop\n"<
bool blExit = false;
bool blSipExit = false;
while(1)
{
EnterCriticalSection(&s_Lock);//处理退出 一般在SIP停止接收后退出。
blExit = s_blExit;
blSipExit = s_blSipExit;
LeaveCriticalSection(&s_Lock);
if (blExit && blSipExit)//待SIP退出服务后再退出。这样最后就可以销毁工作了。
{
break;
}
Sleep(10);
}
libvlc_vlm_stop_media(vlc, media_name);
libvlc_vlm_release(vlc);
cout<<"\nvlc play media =====end========\n"<
vlc = NULL;
return 0;
}
/*
SDP文件内容:
v=0
o=- 20140233 20140238 IN IP4 10.3.240.155 //#1 IP为接收RTP流的计算机IP
s=rtp PS stream
i=N/A
c=IN IP4 10.3.240.155 //#2 IP为接收RTP流的计算机IP
t=0 0
a=tool:ACME RTSP server
a=recvonly
a=type:broadcast
a=charset:UTF-8
a=framerate:16
m=video 6000 RTP/AVP 96 //#3 ,端口要是偶数
b=RR:0
a=rtpmap:96 MP2P/90000
*/