vlc -vvv test.mp4 --sout "#dst=rtp{dst=127.0.0.1,port-audio=20000,port-video=20002,ttl=127,name=CHANNEL,sdp=file:///f:/channel.sdp}"执行上面的命令,将生成一个sdp描述文件channel.sdp,VLC将向指定目的IP的指定port发送RTP包。为确保命令正确,在VLC的菜单"工具"->"消息"中查看是否有错误信息,正常情况下在"消息"窗口中可以看到生成的SDP信息。将channel.sdp复制到目标PC上DSS媒体文件所在目录,这时用VLC直接打开channel.sdp就能播放,如果用mplayer不能直接打开*.sdp文件,应该使用命令"mplayer sdp://channel.sdp"。启动DSS,通过"rtsp://<DSS IP>/channel.sdp"即可连接到DSS。
$ ./testMPEG4VideoToDarwin.exe 127.0.0.1 Beginning streaming... Beginning to read from file... Play this stream (from the Darwin Streaming Server) using the URL: rtsp://127.0.0.1/test.sdp ...done reading from file Beginning to read from file...现在打开DSS的Movies目录,可以发现自动生成了一个test.sdp的文件,使用VLC打开rtsp://<DSS IP>/test.sdp, 即可播放。
$ ./testMPEG4VideoToDarwin.exe 192.168.1.188 Beginning streaming... Beginning to read from file... injector->setDestination() failed: 401 Unauthorized提示信息很明显,跟权限有关。在Movies目录建立一个文本文件"qtaccess",内容如下:
<Limit WRITE> require any-user </Limit> require any-user保存后,重新启动DSS服务,然后再次测试应该就没有问题了。
$ ./testMPEG4VideoToDarwin.exe 192.168.1.188 Beginning streaming... Beginning to read from file... Play this stream (from the Darwin Streaming Server) using the URL: rtsp://192.168.1.188/test.sdp上面的权限配置充许任何用户登录,也可以不提供用户名和密码,默认情况下使用127.0.0.1这个地址时,拥有所能的权限。关于DSS权限控制更多的内容参考http://manuals.info.apple.com/en/quicktimestreamingsrvradminguide.pdf。
使用Wireshark抓取的RTSP命令交互过程如下:
PS:
如果其它PC的无法连接到DSS服务器,可以关闭防火墙试试,我的win7默认就出现这个问题。