CONTENTS

Home
Updates
Software
Electronics
Android / iOS
Videos
Music
Resume
Contact



HTTPS VERSION


Axis Camera DBus

Posted: April 4, 2011

Related pages on www.mikekohn.net: Naken Web, Linux PTZ Control, j2me ipcamview, Axis DBus

Introduction

So I recently needed the ability to get an Axis camera to stream video to a Wowza Media Server without Wowza requesting the video. The idea being as soon as the camera is turned on, video starts playing. First I tried a small script that would make a socket connection to the camera and in the SETUP using the Transport: header to give it a new destination. The camera didn't like this. Next I played the idea of a little redirection program using my libkohn_rtsp.so that could be compiled to run on the camera. While putting this on the camera, I found the camera has Gstreamer, a Gstreamer plugin for their video (libgstartpec.so), and an executable called monolith that uses Gstreamer for the RTSP. After picking around in the monolith executable I realized it exposes control methods through DBus.

Disclaimer

So I should probably say that I don't work for Axis or am associated with them in any way, except that I'm a big fan of their cameras :). Since I didn't find any easily available documentation on the DBus interface in the camera on Axis's site, I hope Axis doesn't mind I'm posting this. I can't imagine it would be a problem anyway since being able to control video on a camera using DBus should be a pretty big selling point.

Cameras

So DBus doesn't seem to be available on cameras with firmware lower than 5.x. I've tested this on the following:

Axis M1114, Axis M1031-W

Commands

Find out what destinations are available on the DBus.

dbus-send --system --print-reply --dest=org.freedesktop.DBus --type=method_call /org/freedesktop/DBus org.freedesktop.DBus.ListNames

Find out what objects are available on your camera through DBus:

dbus-send --system --print-reply --dest=com.axis.Streamer --type=method_call /com/axis/Streamer org.freedesktop.DBus.Introspectable.Introspect

Find out what methods are available for the RTP object:

dbus-send --system --print-reply --dest=com.axis.Streamer --type=method_call /com/axis/Streamer/RTP org.freedesktop.DBus.Introspectable.Introspect

So RTP has a method called CreatePipeline that takes 5 paramters and returns a on object path (reference). I think the paramters are pretty obvious, but just in case: the path and options are pretty much what's put in the RTSP URL: rtsp://cameraip/axis-media/media.amp?videocodec=h264 .. the /axis-media/media.amp becomes the path and vcodec=h264 are the options. Destination and port parameters are the computer and port that will receive the RTP packets. TTL is the time to live on the packets.

Create an RTP object

dbus-send --system --print-reply --dest=com.axis.Streamer --type=method_call /com/axis/Streamer/RTP com.axis.Streamer.RTP.CreatePipeline string:'/axis-media/media.amp' string:'&vcodec=h264' string:'192.168.1.104' int32:10000 int32:1

This will return something like:
method return sender=:1.2 -> dest=:1.217 reply_serial=2
string "/com/axis/Streamer/RTP/Pipeline/2601122334"

So this gives back a newly created RTP object that we can use to start or pause video.

Check what RTP objects are created:

dbus-send --system --print-reply --dest=com.axis.Streamer --type=method_call /com/axis/Streamer/RTP/Pipeline org.freedesktop.DBus.Introspectable.Introspect

Check what methods are available for my new RTP object:

dbus-send --system --print-reply --dest=com.axis.Streamer --type=method_call /com/axis/Streamer/RTP/Pipeline/2601122334 org.freedesktop.DBus.Introspectable.Introspect

Start video playing on this object:

dbus-send --system --print-reply --dest=com.axis.Streamer --type=method_call /com/axis/Streamer/RTP/Pipeline/2601122334 com.axis.Streamer.RTP.Pipeline.Play

Stop video playing on this object and destroy it:

dbus-send --system --print-reply --dest=com.axis.Streamer --type=method_call /com/axis/Streamer/RTP/Pipeline/2601122334 com.axis.Streamer.RTP.Pipeline.Destroy

For both audio and video, it seems they have to be started separately:

dbus-send --system --print-reply --dest=com.axis.Streamer --type=method_call /com/axis/Streamer/RTP com.axis.Streamer.RTP.CreatePipeline string:'/axis-media/media.amp/trackID=1' string:'&vcodec=h264' string:'192.168.1.104' int32:10002 int32:1 And
dbus-send --system --print-reply --dest=com.axis.Streamer --type=method_call /com/axis/Streamer/RTP com.axis.Streamer.RTP.CreatePipeline string:'/axis-media/media.amp/trackID=2' string:'&vcodec=h264' string:'192.168.1.104' int32:10004 int32:1

To get an object's properties:

dbus-send --system --print-reply --dest=com.axis.Streamer --type=method_call /com/axis/Streamer/RTP org.freedesktop.DBus.Properties.Get string:com.axis.Streamer.RTP string:TTL

Copyright 1997-2018 - Michael Kohn