src/rtsp_session.cpp
/**
   Read from our socket, parsing commands as possible.
 */
Read from our socket, parsing commands as possible.
Read from our socket parsing commands as possible .
int rtsp_handle_requests(rtsp_session_t *session, uint32_t readTimeoutMs)
{
    if (!(session->state & 0x01)) {
        return -1;    
    }
    char *buffer = (char *)session->RecvBuf;
    memset(buffer, 0x00, RTSP_BUFFER_SIZE);
    int res = socketread(session->client_socket, buffer, RTSP_BUFFER_SIZE, readTimeoutMs);
    if (res > 0) {
        if (0 == ParseRtspRequest(session, buffer, res)) {
            uint32_t length = RTSP_BUFFER_SIZE;
            switch (session->method) {
            case RTSP_OPTIONS: Handle_RtspOPTION(session, buffer, &length);
                break;
            case RTSP_DESCRIBE: Handle_RtspDESCRIBE(session, buffer, &length);
                break;
            case RTSP_SETUP: Handle_RtspSETUP(session, buffer, &length);
                break;
            case RTSP_PLAY: Handle_RtspPLAY(session, buffer, &length);
                break;
            default: break;
            }
            socketsend(session->client_socket, buffer, length);
        } else {
            ESP_LOGE(TAG, "rtsp request parse failed");
        }
        if (session->method == RTSP_PLAY) {
            session->state |= 0x02;
        } else if (session->method == RTSP_TEARDOWN) {
            session->state &= ~(0x02);
        }
    } else if (res == 0) {
        ESP_LOGI(TAG, "client closed socket, exiting");
        session->state = 0;
        return -3;
    } else  {
        return -2;
    }
    return 0;
}
int rtsp_handle_requests ( rtsp_session_t * session , uint32_t readTimeoutMs ) { if ( ! ( session -> state & 0x01 ) ) { return -1 ; } char * buffer = ( char * ) session -> RecvBuf ; memset ( buffer , 0x00 , RTSP_BUFFER_SIZE ) ; int res = socketread ( session -> client_socket , buffer , RTSP_BUFFER_SIZE , readTimeoutMs ) ; if ( res > 0 ) { if ( 0 == ParseRtspRequest ( session , buffer , res ) ) { uint32_t length = RTSP_BUFFER_SIZE ; switch ( session -> method ) { case RTSP_OPTIONS : Handle_RtspOPTION ( session , buffer , & length ) ; break ; case RTSP_DESCRIBE : Handle_RtspDESCRIBE ( session , buffer , & length ) ; break ; case RTSP_SETUP : Handle_RtspSETUP ( session , buffer , & length ) ; break ; case RTSP_PLAY : Handle_RtspPLAY ( session , buffer , & length ) ; break ; default : break ; } socketsend ( session -> client_socket , buffer , length ) ; } else { ESP_LOGE ( TAG , " " ) ; } if ( session -> method == RTSP_PLAY ) { session -> state |= 0x02 ; } else if ( session -> method == RTSP_TEARDOWN ) { session -> state &= ~ ( 0x02 ) ; } } else if ( res == 0 ) { ESP_LOGI ( TAG , " " ) ; session -> state = 0 ; return -3 ; } else { return -2 ; } return 0 ; }
Read from our socket, parsing commands as possible.
Read from our socket parsing commands as possible .
// Already closed down
