Syntax

int (* event_callback)(
    void *opaque,
    int type,
    void *data,
    long long data_size
);          

Parameters

Parameter Description
opaque The value of the MessageCbParam parameter that was set when the preconfig function was called. RTS SDK returns the initial value to event_callbac.
type The ID of the message.
data The content of the message. The format of the message is when=<time_in_ms>,where=<place>,who=<id>,desc=<extra text>. This parameter is a temporary parameter that will be deleted after the callback function is called.
data_size The length of the message content. Unit: bytes.

Message IDs

Message ID Description
100 The Help support ID message. It is returned before a connect operation is performed.
102 The Help support ID message. It is returned during a connect operation.
103 The Help support ID message. It is returned during a stream ingest.
104 The Help support ID message. It is returned during a stream pulling.
105 The message that is used to collect data every 4 seconds.
Note If the ID of a returned message is 105, the content format of desc is \"key1:val1,key2:val2,... \".
20000 ~ 30000 The error codes.
20001 A DNS error occurs. The domain name cannot be resolved.
20002 Domain access verification failed.
20009 A streaming media server is connected.
20010 Connection to a streaming media server failed.
20012 The stream to which you subscribe has timed out.
20013 The stream to which you subscribe does not exist.
20014 The stream to which you subscribe contains no audios.
20015 The stream to which you subscribe contains no videos.
20020 Other unknown subscription errors have occurred.
20050 The packet loss rate is high and severe congestion has occurred.
20051 The packet loss rate has dropped to a normal level and congestion is solved.
20052 The stream is interrupted. No audio or video packets exist.
20053 The stream is resumed.
20054 End of the stream.
20055 The stream is disconnected.
20056 A stream is detected and played again.
20057 A playback error has occurred. Downgrade the stream to a Real-Time Messaging Protocol (RTMP) stream.

Example

For information about how to configure the message callback function for RTS SDK by calling the preconfig function, click Download SDK to see the rtsdec.c file in the RTS SDK for a mobile client.

static int on_message(void *s,
                      int type,
                      void *data,
                      long long data_size)
{
    (void) s;

    //TODO: process message, do not take too long
    switch(type) {
    case 105:
        printf("Profiling message %s.\n", (const char *)data);
        break;
    default:
        break;
    }
    return 0;
}

__rts_funcs->preconfig("MessageCallback", addr_to_string(on_message, buf));
__rts_funcs->preconfig("MessageCbParam", addr_to_string(s, buf));