Video channel

Video channel is implemented with private binary protocol, which has header and data parts.

Main Header

Size, Bytes

Name

Type

Description

16

Video ID

GUID

Retrieved from the Meta channel. Used as a start code and a frame separator.

8

Time Stamp UTC

LONG

Milliseconds since 1st January 1970 (UTC)

4

Frame Count

UINT

Number of frame (probably won’t be necessary)

4

Frame Size Bytes

UINT

Size in bytes of the following data part

2

HeaderSizeBytes

USHORT

Total size of headers in bytes including this Main header. (So the value will always be 36 or more).

If the vaule is zero, however, it has special meaning that the Main header contains additional 4-byte "HeaderSizeBytesExt" field (effectively making the Main header 40 bytes long).

2

HeaderExtensionFlags

USHORT

Bit mask which describes which extension headers presents.

4

HeaderSizeBytesExt

(optional)

UINT

Total size of headers in bytes including this Main header. (So the value will always be 40 or more).
This additional field is present only if the ordinary "HeaderSizeBytes" field has value of zero. Otherwise this field is never present.
It is allowed this filed to present even if total lenght of headers could be described with 2 bytes.

Header Extension sizes

Headerflag - 0x01

Size, Bytes

Name

Type

Description

4

SrcStrideX

INT

Camera original source width.

4

SrcStrideY

INT

Camera original source height.

4

SrcLeft

INT

Cropping rectangle left.

4

SrcTop

INT

Cropping rectangle top.

4

SrcRight

INT

Cropping rectangle right.

4

SrcBottom

INT

Cropping rectangle bottom.

4

DestStrideX

INT

Rescaled picture destination width.

4

DestStrideY

INT

Rescaled picture destination height.

4

ResamplingTag

INT

- Mobile client or Mobile Server does not support decimal resampling factor- 1,2 or 4. Indicates the multiplier that will yield the original number of pixels.

Mobile client and Mobile Server support support decimal resampling factor – divide the value by 106 (ex. Value = 1234567, Resampling factor = 1.234567)

4

Reserved

INT

Not used.

4

Reserved

INT

Not used.

4

Reserved

INT

Not used.

Header Extension live events

Headerflag - 0x02

Size, Bytes

Name

Type

Description

4

CurrentFlags

UINT

Bit mask for current flags state.

4

ChangedFlags

UINT

Bit mask for changed flags state (since previous state).

Available flags:
•   LiveFeed = 1,
•   Motion = 2,
•   Recording = 4,
•   Notification = 8,
•   CameraConnectionLost = 16,
•   DatabaseFail = 32,
•   DiskFull = 64,
•   ClientLiveStopped = 128,

Header Extension playback events

Headerflag - 0x04

Size, Bytes

Name

Type

Description

4

CurrentFlags

UINT

Bit mask for current flags state.

4

ChangedFlags

UINT

Bit mask for changed flags state (since previous state).


Available Flags:
•   PlayStopped = 0x1,
•   PlayForward = 0x2,
•   PlayBackward = 0x4,
•   DatabaseStart = 0x10,
•   DatabaseEnd = 0x20,
•   DatabaseError = 0x40,
•   RangeNoData = 0x100,
•   OutOfRange = 0x200,

Header Extension Native Data Headers

Headerflag - 0x08

Size, Bytes

Name

Type

Description

4

NativeDataHeaderSize

UINT

Size of the whole group of native header extensions

4

NativeDataExtensionsFlags

UINT

Flags specifying which of the native data header extensions are included.

This header serves as the main header of the native data headers. The first value is the size of the whole group of native headers extensions. The second value is a bitmask stating which of the extended native data headers are included on the current native data frame. The next four sections will describe each of these extensions.

Native Data Header extension - Playback SyncPoint

Native Data Header flag - 0x01

Size, Bytes

Name

Type

Description

8

PreviousSyncTimeStamp

ULONG

Time stamp of previous sync-point in playback stream.

8

NextSyncTimeStamp

ULONG

Time stamp of next sync-point in playback stream.

The time stamp of the previous and next sync point is used by the Milestone decoders and must be accessible on a Native Stream in Playback Mode. Note that this header extension is required on a sync point, i.e. an I-frame in H.264 but it should not be set on other media data frames. The time stamps are available through the Image Server Source Toolkit and needs to be throught the MIP SDK along with the media data. These time stamps are not used in live mode and this header extension should therefore not be sent.

Native Data Header extension -Native Playback Header

Native Data Header flag - 0x02

Size, Bytes

Name

Type

Description

8

SequenceId

ULONG

Sequence Id of the current frame

2

HasMotion

UINT16

Flag stating whether the current frame has motion.

The SequenceId and HasMotion flags can be used to recreate the sequence and time line information available on the server. This is of great importance for the Media Storage Export Toolkit for instance. In contrast to native playback sync point header extension described in the previous section this header should be set on all media data frames, including sync points. The SequenceId and HasMotion header values are not used in live mode and this header extension should therefore not be included.  

Native Data Header extension - Privacy Mask

Native Data Header flag - 0x04

Size, Bytes

Name

Type

Description

4

PrivacyMaskState

UINT

State of the privacy mask.

4

PrivacyMaskLength

UINT

Length of privacy mask string in bytes.

VAR

PrivacyMask

STRING

Privacy mask string in standard ASCII format.

Today the privacy mask is added to the images by the Mobile Server during transcoding. We have to do something similar in the Direct Streaming decoders and hence we need the privacy mask streamed as a string (no zeros and thus not zero-terminated, nor CRLF-terminated). This can for instance be handled as a chunk of binary data. The privacy mask header can be set on both sync points media data frames and regular media data frames. Furthermore, privacy masks are set for both Live and Playback Streams and this header extension therefore has to be permitted in both modes.
This header should not be sent if no privacy mask is specified on the server.
Assuming a privacy mask has been specified at least one of the following conditions have to be met when determining whether to add a privacy mask header extension:
1. The media frame is the first one being sent after the RequestStream call.
2. The privacy mask has changed since sending the last frame and must be changed for the current.

The reason for the second condition is that it is assumed that clients cache the current privacy mask.

Native Data Header extension - Signature

Native Data Header flag - 0x08

Size, Bytes

Name

Type

Description

4

SignatureState

UINT

State of the signature.

4

SignatureLength

UINT

Length of signature string.

VAR

Signature

STRING

Signature string in standard ASCII format.


Database signing was a feature added to the Media Storage Database with the XPCO 5.0 release. This involves signing the media data with a certificate and then verifying the signatures during database export. Again the Web and Mobile Client will not have much use for this header extension (for now), but it must be there for later and for third-party SDK use. Contrary to privacy masks media data signatures only exists for recorded data. For that reason this header extension should only be set on media data sent through a Playback Stream.

A signature is calculated for a range of records in the database.
This header should only be sent when signing is enabled by the server, on the first frame that is received on a Playback Stream, and when the signature changes.
Assuming that signing has been enabled on server at least one of the following conditions have to be met when determining whether to add a signature header extension on a media data frame:
1. The media frame is the first one being sent after the RequestStream call.
2. The signature has changed since sending the last frame and must be changed for the current.

The reason for the second condition is that it is assumed that clients cache the current signature.

Header Extension motion events (Arcus only)

Motion Events Header Flag - 0x10

This header is Arcus server specific.

Size, Bytes

Name

Type

Description

4

HeaderSize

UINT

Size of this header.

4

MotionAmmount

UINT

Ammount of motion detected.

Header Extension Location Info (Under Development)

Location Info Header Flag - 0x20

Size, Bytes

Name

Type

Description

4

HeaderSize

UINT

Size of this header.

4

Version

UINT

Version of the location header.

4

Source

UINT

Location data source.

4

Reserved

UINT

Reserved for future use.

4 ValidFields UINT Indicates which of the following fields have valid values.
4 Longitude UINT Longitude in GCS.
4 Latitude UINT Latitude in GCS.
4 Altitude INT Altitude in GCS.
4 HorizontalAccuracy UINT Accuracy of the Longitude and Latitude.
4 VerticalAccuracy UINT Accuracy of the Altitude.
4 Speed UINT Client horizontal speed.
4 Azimuth UINT Angle to the North of the client's direction.

HeaderSize - size of this header in bytes. Currently has a value of 48.

Version - currently this field has only one valie value and this is zero (0).

Source - indicates where the location info comes from. It is a bit field mask with members:

 Unknown = 0,
 Satellite = 0x01,
 WiFi = 0x02,
 Cellular = 0x04,
 IpAddress = 0x08,
 Radio = WiFi | Cellular,

Reserved - allocated for future usage. Currently should have value of zero.

ValidFileds - bitmask which idicates correcteness of data members (Longiture, Latitude, Altitude, Horizontal/Vertical Accuracy, Speed and Azimuth)

 LongitudeMask = 0x01,
 LatitudeMask = 0x02,
 AltitudeMask = 0x04,
 HorizontalAccuracyMask = 0x08,
 VerticalAccuracyMask = 0x10,
 SpeedMask = 0x20,
 AzimuthMask = 0x40

GSC - Geographic coordinate system

Longitude - Specifies the east-west position in degrees.

 It has only positive values - from 0 to 360. Every negative value should be added to 360. For example if (-90) should be expressed, it is equal to 270.

 The value in the field is multiplied with 10^7. For example value of 42.670308 should be written as 426'703'080.

Latitude - Specifies the north-south position in degrees.

 It has only positive values - from 0 to 180. Every negative value should be added to 180. For example if (-36) should be expressed, it is equal to 144.

 The value in the field is multiplied with 10^7. For example value of 23.352784 should be written as 233'527'840.

Altitude - Height above mean see level, measured in centimeters. (1 cm = 10 mm = 0.01 m)

HorizontalAccuracy - Accuracy of the Longitude and Latitude, measured in centimeters.

VerticalAccuracy - Accuracy of the Altitude, measured in centimeters.

Speed - Horizontal velocity (change of the position) in cm/s (centimeters per second)

Azimuth - Angle between client's forward direction and true north in degrees (measured in clockwise direction).

 It has only positive values - from 0 to 360. Every negative value should be added to 360. For example if (-34) should be expressed, it is equal to 326.

 The value in the field is multiplied with 10^7. For example value of 18.234556 should be written as 182'345'560.

Header Extension Stream Info

Stream Info Header Flag - 0x40

Size, Bytes

Name

Type

Description

4

HeaderSize

UINT

Size of this header.

4

Version

UINT

Version of the info header.

4

Reserved

UINT

Reserved for future use.

4

Fields

UINT

Indicates which of the following fields have valid values.

4

TimeBetweenFrames

UINT

In MS

4

DataType

UINT

Four letter data type (e.g. H264, JPEG) of the underlying raw stream

4

Flags

UINT

Streaming info flags

4

Profile

UINT

Video codec profile.

4

Level

UINT

Video codec level.

4

Compatibility

UINT

Video codec compatibility.

8

Constrains

ULONG

Video codec constrains.

4

FramesCount

UINT

Number of frames in current stream segment

HeaderSize - size of this header in bytes. Currently has a value of 52.

Version - current version (3).

Reserved - allocated for future usage. Currently should have value of zero.

Fields - bitmask which indicates correctness of data members

 TimeBetweenFrames = 0x01,
 DataType = 0x02,
 Flags = 0x04
 Profile = 0x08,
 Level = 0x10,
 Compatibility = 0x20,
 Constraints = 0x40,
 FramesCount = 0x80,

DataType - Four letter string byte representation of the stream data type. NULL for not supported, H264, H265, JPEG.
Flags are currently set to 0x01 in case the video data contains key frame.

Header Extension Carousel Info

Carousel Info Header Flag - 0x80

Size, Bytes

Name

Type

Description

4

HeaderSize

UINT

Size of this header.

4

Version

UINT

Version of the header.

16

ItemId

GUID

ID of the current playing camera in the carousel.

HeaderSize - size of this header in bytes. Currently has a value of 24.

Version - currently this field has only one value and this is zero (0).

ItemId - GUID of the camera Item which is currently playing.

Header Extension Dynamic Info

Carousel Info and Error in Audio Push Header Flag - 0x100

Size, Bytes

Name

Type

Description

4

HeaderSize

UINT

Size of this header + size of following data.

4

Version

UINT

Version of the header.

4

DataCount

UINT

Number of data type structers following this header

4

DataType

UINT

Type of the data following this header.

HeaderSize - size of this header + size of following data in bytes.

Version - currently this field has only one value and this is zero (0).

DataCount - Number of data type structures following this header.

DataType - Type of the data following this header.

 HeaderTypeDeviceStateInfo = 0x00

Header Type Device State Info

Type Device State - 0x00

Size, Bytes

Name

Type

Description

16

ItemID

GUID

Id of device (speaker) that has failed.

4

ErrorCode

UINT

Error code

4

Reserved

UINT

Align to 8 bytes

ItemID - Id of device (speaker) that has failed.

ErrorCode - Code of the error. Error codes are defined as Command error codes

Reserved - Align to 8 bytes.

Header Extension Playback Info

Headerflag - 0x200

Size, Bytes

Name

Type

Description

8

RequestedTimeStampUtcMs

ULONG

Time stamp of requested playback image.

4

Reserved

UINT

Not used.

4

Reserved

UINT

Not used.