This topic describes the data structures of Native RTS SDK.

Overview

Data structure Description
rts_worker_demux_info Specifies the media information.
rts_frame Encapsulates audio and video frames.
rts_glue_funcs Specifies the function pointer.
pusher_delay Specifies the stream ingest delay.
player_delay Specifies the stream pulling delay.

Details

  • rts_worker_demux_info: specifies the media information.
    struct rts_worker_demux_info
    {
        int audio_flag;
        int audio_channels;
        int audio_sample_rate;
    
        int video_flag;
        int video_codec;
        int video_width;
        int video_height;
        int video_profile;
        int video_level;
    
        unsigned char spspps[10 * 1024];
        int spspps_len;
    };    
    Parameter Description
    audio_flag Specifies whether the subsequent audio information is valid. Valid values:
    • 1: valid
    • 0: invalid
    audio_channels The number of audio channels. This parameter takes effect only if the audio_flag parameter is set to 1.
    audio_sample_rate The audio sampling rate. This parameter takes effect only if the audio_flag parameter is set to 1.
    video_flag Specifies whether the subsequent video information is valid. Valid values:
    • 1: valid
    • 0: invalid
    video_codec The type of the video frame. This parameter takes effect only if the video_flag parameter is set to 1, that is, H.264.
    video_width The width of the video resolution. This parameter takes effect only if the video_flag parameter is set to 1.
    video_height The height of the video resolution. This parameter takes effect only if the video_flag parameter is set to 1.
    video_profile The profile used for video encoding. This parameter takes effect only if both the video_flag and video_codec parameters are set to 1.
    video_level The level used for video encoding. This parameter takes effect only if both the video_flag and video_codec parameters are set to 1.
    spspps Stores sequence parameter set (SPS) and picture parameter set (PPS) information. This parameter can be used to initialize the decoder in advance. It can be left empty. This parameter takes effect only if both the video_flag and video_codec parameters are set to 1.
    spspps_len The length of spspps. Unit: byte. This parameter takes effect only if both the video_flag and video_codec parameters are set to 1.
  • rts_frame: encapsulates audio and video frames.
    struct rts_frame
    {
        void *buf;              // where frame data is stored
        int size;               // size of frame data in bytes
        int is_audio;           // 1 for audio frame, 0 for video frame
        unsigned long long pts; // presentation time stamp, in ms
        unsigned long long dts; // decoding time stamp, in ms
        int flag;               // for video frame (is_audio == 0)
                                // bit 0: key frame
                                // bit 1: corruption
                                // bit 2: sps
                                // bit 3: sps change
        int duration;           // in ms
        // use this function to free rts_frame object
        void (*free_ptr)(struct rts_frame *);
        unsigned int uid; // reserved.
        struct pusher_delay delay;
        // msid-value = msid-id [ SP msid-appdata ]
        char msid[NET_MSID_MAX_LENGTH + 1];
    };                
    Parameter Description
    buf The buffer of the frame.
    size The buffer size. Unit: byte.
    is_audio Specifies whether the frame is an audio frame. Valid values:
    • 1: audio frame
    • 0: video frame
    pts The presentation timestamp. Unit: milliseconds.
    dts The decoding timestamp. Unit: milliseconds.
    flag This parameter takes effect only if the is_audio parameter is set to 0. Valid values:
    • 1: damage flag
    • 0: keyframe flag
    duration The duration of the frame. Unit: milliseconds.
    free_ptr The function pointer that is called to release the current rts_frame object. Example: frm->free_ptr(frm);.
    uid The reserved parameter that specifies the stream to which data belongs.
    delay The data structure used to record the stream ingest delay. For more information, see pusher_delay.
  • rts_glue_funcs: specifies the function pointer.
    struct rts_glue_funcs
    {
        int api_version;
        int (* preconfig)(const char *key, const char *val);
        void (* open)(const char *url, const char mode);
        void (* close)(void handle);
        long long (* ioctl)(void *handle, const char *cmd, void arg);
        int (* read)(struct rtsframe **frame, void handle);
        int (* write)(struct rtsframe **frame, void *handle);
    };
    Parameter Description
    api_version The API version. Set the value to 2.
    preconfig The function that you call when you set a global parameter. You must call the preconfig function before you call the open function. For more information, see Functions.
    open Opens a stream. For more information, see Functions.
    close Closes a stream. For more information, see Functions.
    ioctl Sets and queries a parameter. For more information, see Functions.
    read Reads a data frame. For more information, see Functions.
    write Sends a data frame. For more information, see Functions.
  • pusher_delay: specifies the stream ingest delay.
    struct pusher_delay
    {
        long long cap_time_ms;  //current utc time when capture the video frame
        long long enc_time_ms;  //current utc time when the videoframe send to encoder
    };                
    Note
    For stream ingest over Real-Time Messaging Protocol (RTMP) in Real-Time Streaming (RTS), you can insert supplemental enhancement information (SEI) to count the end-to-end delay. gdelay is the sum of all delays instead of the current delay. Unit: milliseconds.
    {
        "gdelay":100
    }
    Parameter Description
    cap_time_ms The system time when an image is collected. Unit: milliseconds. The value must be a UNIX timestamp representing the number of milliseconds that have elapsed since the epoch time January 1, 1970, 00:00:00 UTC.
    enc_time_ms The system time when the collected image is fed into the encoder. Unit: milliseconds. The value must be a UNIX timestamp representing the number of milliseconds that have elapsed since the epoch time January 1, 1970, 00:00:00 UTC.
  • player_delay: specifies the stream pulling delay.
    struct player_delay
    {
        long long decoder_time_ms;  //current utc time when the video frame send to decoder
        long long render_time_ms;   //current utc time when the video frame send to render
        unsigned long long pts;     //the video frame's pts
    };                
    Parameter Description
    decoder_time_ms The time when an image is collected. Unit: milliseconds. The time must be in Coordinated Universal Time (UTC).
    render_time_ms The time when the collected image is fed into the encoder. Unit: milliseconds. The time must be in UTC.
    pts The presentation timestamp. Unit: milliseconds.