Atitit onvif协议获取rtsp地址播放java语言 attilx总结

 

 

Atitit onvif协议获取rtsp地址播放java语言 attilx总结

 

 

1.1. 获取rtsp地址的算法与流程1

1.2. Onvif摄像头的发现,ws的发现机制,使用xcf类库1

2. 调用getStreamUri 获得rtsp地址 ,使用类库ONVIF Java Library by Milgo2

2.1. 问题为什么使用这个得到的地址不能播放4

 

 

 

1.1. 获取rtsp地址的算法与流程 

动态发现onvif设备

调用getProfiles  获取Profile列表,

调用getStreamUri 获得rtsp地址 ( 使用Profile参数)

 

 

 

1.2. Onvif摄像头的发现,ws的发现机制,使用xcf类库

 

Onvif协议建立在webservice协议基础上。他的发现机制就是ws的发现机制。。

 

import java.util.List;

import javax.xml.ws.EndpointReference;

import org.apache.cxf.ws.discovery.WSDiscoveryClient;

 

public class Main

{

    public static void main(String[] args)

    {

        WSDiscoveryClient client = new WSDiscoveryClient();

        client.setVersion10(); // use WS-discovery 1.0

        client.setDefaultProbeTimeout(1000); // timeout 1s

 

        System.out.println("Probe:" + client.getAddress());

        List<EndpointReference> references = client.probe();

 

        System.out.println("Nb answsers:" + references.size());

        for (EndpointReference ref : references)

        {

            System.out.println(ref.toString());

        }

    }

}

Probe is :soap.udp://239.255.255.250:3702

Nb answsers:1

<?xml version="1.0" encoding="UTF-8" standalone="yes"?><EndpointReference xmlns="http://www.w3.org/2005/08/addressing"><Address>http://192.168.31.144:10080/onvif/device_service</Address><ReferenceParameters/></EndpointReference>

 

 

返回的ws服务地址  http://192.168.31.144:10080/onvif/device_service

 

2. 调用getStreamUri 获得rtsp地址 ,使用类库ONVIF Java Library by Milgo

根据上异步获得的ws服务地址,提取ipport。。调用getStreamUri 获得rtsp地址

 

返回的rtsp地址  rtsp://192.168.31.144:10554/tcp/av0_0

 

 

package com.attilax.video;

 

/**

 * @author attilax

 *2016年12月21日 下午10:38:11

 */

import java.io.IOException;

import java.net.ConnectException;

import java.util.List;

 

import javax.xml.soap.SOAPException;

 

import org.onvif.ver10.media.wsdl.GetStreamUri;

import org.onvif.ver10.media.wsdl.GetStreamUriResponse;

import org.onvif.ver10.schema.Profile;

import org.onvif.ver10.schema.StreamSetup;

import org.onvif.ver10.schema.Transport;

 

import de.onvif.soap.OnvifDevice;

 

public class OnvifTest {

public static void main(String[] args) {

// org.apache.commons.codec.binary.Base64

// org.apache.commons.codec.binary.Base64

try {

// OnvifDevice nvt = new OnvifDevice("192.168.0.20", "admin",

// "password");

OnvifDevice nvt = new OnvifDevice("192.168.31.144:10080", "", "");

List<Profile> profiles = nvt.getDevices().getProfiles();

for (Profile profile : profiles) {

// String profileToken = profiles.get(0).getToken();

System.out.println(profile);

}

 

// System.out.println("Snapshot URI: "+nvt.getMedia().getSnapshotUri(profileToken));

String profileToken = profiles.get(0).getToken();  //PROFILE_000

StreamSetup streamSetup = new StreamSetup();

String getStreamUri = nvt.getMedia().getStreamUri(profileToken, streamSetup);

System.out.println("getStreamUri:" + getStreamUri);

} catch (ConnectException e) {

System.err.println("Could not connect to NVT.");

} catch (SOAPException e) {

e.printStackTrace();

}

}

 

 

 

 

2.1. 问题为什么使用这个得到的地址不能播放

 

返回的rtsp地址  rtsp://192.168.31.144:10554/tcp/av0_0

 

使用VLC播放器和onvif测试工具都不能播放。。设备也没有设置用户名密码的。

 

 

作者:: 绰号:老哇的爪子claw of Eagle 偶像破坏者Iconoclast image-smasher

捕鸟王"Bird Catcher 王中之王King of Kings 虔诚者Pious 宗教信仰捍卫者 Defender Of the Faith. 卡拉卡拉红斗篷 Caracalla red cloak

简称:: Emir Attilax Akbar 埃米尔 阿提拉克斯 阿克巴

全名::Emir Attilax Akbar bin Mahmud bin  attila bin Solomon bin adam Al Rapanui 埃米尔 阿提拉克斯 阿克巴 马哈茂德  阿提拉 所罗门 本亚当  阿尔 拉帕努伊

常用名:艾提拉(艾龙),  EMAIL:1466519819@qq.com

 

 

头衔:uke总部o2o负责人,全球网格化项目创始人,

uke宗教与文化融合事务部部长, uke宗教改革委员会副主席

Uke部落首席大酋长,

uke制度与重大会议委员会委员长,uke保安部首席大队长,uke制度检查委员会副会长,

奶牛科技cto ,uke 首席cto

uke波利尼西亚区大区连锁负责人,克尔格伦群岛区连锁负责人,莱恩群岛区连锁负责人,uke汤加王国区域负责人。布维岛和南乔治亚和南桑威奇群岛大区连锁负责人

 Uke软件标准化协会理事长理事长 uke终身教育学校副校长

Uke 数据库与存储标准化协会副会长 uke出版社编辑总编

Uke医院方面的创始人

 

转载请注明来源:attilax的专栏  ?http://www.cnblogs.com/attilax/

--Atiend

 

 

 

posted @ 2016-12-23 16:17  attilaxAti  阅读(711)  评论(1编辑  收藏  举报