Version | Date | Change Log |
---|---|---|
V1.0.00 | 2008/09/07 |
|
V1.0.01 | 2008/09/08 |
|
V1.0.02 | 2012/07/19 |
|
To support the video and audio streaming on the DI and motion triggered on TCP 2.0 protocol, the TCP protocol 2.0 needs to be modified. In this document, it defined the new data structure of authentication packet and updated video and audio stremaing protocol based on TCP 2.0 protocol.
In TCP 2.0, the device follows the remote host authentication request to service the video and audio stream. Adapt to this design, the host could request device to upload stream when the his interested event occurs during authentication process. Currently, the available events are DI and motion detection (included PIR) events. The output frames from device depend on the DI and motion states.
The remote host could decide if the device pauses the stream automatiocally or not. The upload time is needed when the mechanism of pause is done by device.
- If the DIs and motion state are not changed and the registered events are not occurs, the device will upload the Video B2 frame every seconds.
- If the DIs or motion state is changed but the registeded events are not triggered, the device will send the video B2 frame immediately. The device sends video B2 frame again after 1 second if the DIs and motion state are not changed and registered events are not triggered.
- If the registered event are triggered, the device sends pre-buffer video and audio frames first. Then, keep uploading the video and audio frames to the remote host.
The StreamByEvent is the element of authentication packet. It describes how to handle the video and audio stream.
// definitions in CondDI and CondMD in StreamByEvent #define SEND_AS_CONNECTED 0x00 // The device starts sending video and audio stream to remote client as the authentication is successful. // definitions in CondDI in StreamByEvent #define SEND_AS_DI1 0x01 // The device starts sending video and audio stream to remote client as DI1 is at triggered level. #define SEND_AS_DI2 0x02 // The device starts sending video and audio stream to remote client as DI2 is at triggered level. // definitions in CondMD in StreamByEvent #define SEND_AS_MD1 0x01 // The device starts sending video and audio stream to remote client as Motion Region 1 is at triggered level. #define SEND_AS_MD2 0x02 // The device starts sending video and audio stream to remote client as Motion Region 2 is at triggered level. #define SEND_AS_MD3 0x04 // The device starts sending video and audio stream to remote client as Motion Region 3 is at triggered level. #define SEND_AS_PIR 0x80 // The device starts sending video and audio stream to remote client as PIR is at triggered level. // definitions in CondPAUSE in StreamByEvent #define PAUSE_BY_HOST 0x00 // The device sends the stream until the remote host sends PAUSE frame or closes the session. #define PAUSE_BY_DEVICE 0x01 // The device sends the stream until the remote host sends PAUSE frame or closes the session or the upload time is expired. typedef struct { char Ver; // The version of this protocol. It is fixed to 'E'. This tStreamByEvent is valid if only if this Ver = 'E'. char CondDI; // The condition of DIs for uploading video and audio. Refer to definition of CondDI. char CondMD; // The condition of motion detction for uploading video and audio. Refer to definition of CondMD. char CondPause; // The condition of motion detction for pause of uploading video and audio. Refer to definition of CondPause. int UploadTime; // This field is effective if only if CondPause = PAUSE_BY_DEVICE.
The time in seconds of uploading video and audio when the DI/Motion states in encoder meet CondDI or CondMD.
The range of UploadTime is from 0 to 3600 seconds. 0 means the device pauses the stream as the event is inactive.} tStreamByEvent;
CondDI
The definition of DI triggered is the target DI's signal level becomes HIGH level. The DI timer in the firmware controls the DI event state. Please refer to the Control Session Design Specification.
CondMD
The motion detection timer in the firmware controls themotion event state. Please refer to the Control Session Design Specification.
Note that the bitmap in CondMD is different from the bitmap in the motion message in control session.CondPause
When CondPause = PAUSE_BY_HOST, the device keeps uploading the stream to host until it receives PAUSE frame or host closes the streaming session.
When CondPause = PAUSE_BY_DEVICE, the device keeps uploading the stream to host until it receives PAUSE frame or host closes the streaming session or the upload time is expired.When UploadTime = 0, the device stops uploading stream when the event became inactive.
When UploadTime is not 0, the device keeps uploading the stream to host until the upload time is expired. When the event changes to inactive during upload, the device does not stop uploading stream. Successive events during upload time will be ignored.
The firmware keeps sending the video stream to remote host if the UploadTime is expired but the trigger source is still active. The firmware stops sending video stream to remote host until the trigger source becomes inactive then.Pre-buffer upload
The device starts from pre-buffer upload when the event is triggered. The length of pre-buffer depends on video resolution, frame rate, bit rate and platform. In platformA mega-pixel camera, the pre-buffer length is around 1 second. In platformA VGA camera, the pre-buffer length is 3 seconds. In platformT camera, the pre-buffer length is 3 seconds.
The video B2 in the pre-buffer will NOT be chagned during upload. That means the DI and motion do not show the event was triggered.
The DIs and motion indications in the video B2 frames in this extended TCP 2.0 protocol are different from TCP 2.0 video B2 frames' DIs and motion indications. Except DIs and motion indications, the rest of B2 data is the same in these two protocols.
In TCP 2.0 video B2 frame, the DIs and motion state is updated by frame basis. The DI and motion timer do not affact these indications in video B2 frames.
In this Event Triggered Streaming Protocol, the DIs and motion indications in video B2 frames are controlled by DI and motion timers.
The time interval of two successive video B2 frame is 1 second. When the DIs or motion states were changed, the device will send the video B2 frame immediately. The video / audio data upload depends on if CondDI and CondMD match the device's DIs and motion states.This follwing figure illustrates how the video B2 frames are sent based on DIs and motion events. Assume the host registered the MD1 event for video upload in the authentication process.
![]()
Event is NOT active
The device will send one video B2 frame per second. No audio frame was sent when the Audio In function is enabled.
The time stamp in the B2 frame should not be taken. It is just for tracking the stream session is alive.Event becomes active
The device will send video stream based on its video configurations. The audio frames were sent when the Audio In function is enabled.
The formats of the video and audio frames are the same as them in TCP 2.0 streaming protocol.
The DI and motion indications in video B2 frames follow event states which were managed by DI and Motion timers. These indications are different from the video B2 frames defined in TCP 2.0 streaming protocol.When receive PAUSE frame
The device will stop sending stream as it receives the PAUSE frame no matter the event state and upload time is expired or not. New event will trigger the device to upload stream again.When host closes the session
The device will close the streaming session when it detects the host closed the session. The event associated with this session will be removed as well. The event in other session will not be affected.
The PAUSE frame is the streaming control message defined in the TCP 2.0 streaming protocol. The format of this frame is
The STREAM_PAUSE_OFF frame will be ignored by device when one of the following conditions is matches.
- The MsgType is MSG_PAUSE_CTRL in the PAUSE frame header
- The msg[0] in the STREAM_MSG is STREAM_PAUSE_ON
- CondDI is not SEND_AS_CONNECTED
- CondMD is not SEND_AS_CONNECTED
- CondPause is not PAUSE_BY_HOST
The following figure illustrates how the stream on event control. The event source is DI. The remote host will send PAUSE frame to hold device streaming.
![]()
Streaming Protocol in TCP 2.0
Function Availability with Platform Firmware