[Live-devel] videowidth,videoheight,fps and buffer

osman osman herneolursa at gmail.com
Sat May 31 10:36:00 PDT 2008


Hello,
I'm a student and beginner with the live555 library.
I have been writing some simple test programs for handling rtsp streaming.
Now I'm trying take only videowidth,videoheight,fps and buffer from
streaming.
I'm make use of mplayer source code. But mplayer using demux_t class for
handling buffer.
This is too complex for me.
What is the simply way for taking (videowidth,videoheight,fps and buffer)
this data? Thanks.

Here source codes
#include "rtspdene.h"
#include "BasicUsageEnvironment.hh"
#include "GroupsockHelper.hh"
#include <stdio.h>

int rtspStreamOverTCP = 0;
char* network_username;
char* network_password;


static char* openURL_rtsp(RTSPClient* client, char const* url) {
  // If we were given a user name (and optional password), then use them:
  if (network_username != NULL) {
    char const* password = network_password == NULL ? "" : network_password;
    return client->describeWithPassword(url, network_username, password);
  } else {
    return client->describeURL(url);
  }
}

int main()
{
    char const* url = "rtsp://192.168.2.200:554";
    Boolean success = False;
    do {

        TaskScheduler* scheduler = BasicTaskScheduler::createNew();
        if (scheduler == NULL)
        {
            printf("BasicTaskScheduler::createNew hata");
            break;
        }

        UsageEnvironment* env =
BasicUsageEnvironment::createNew(*scheduler);
        if (env == NULL)
        {
            printf("BasicUsageEnvironment::createNew hata");
            break;
        }

        RTSPClient* rtspClient = NULL;

        rtspClient = RTSPClient::createNew(*env, 1, "MRT");
        if (rtspClient == NULL)
        { printf("Failed to create RTSP client"); }

        char* sdpDescription = NULL;
        sdpDescription = openURL_rtsp(rtspClient,url);

        if (sdpDescription == NULL) {
            printf( "Failed to get a SDP description from URL \"%s\": %s\n",
url, env->getResultMsg());
            break;
        }

        // Now that we have a SDP description, create a MediaSession from
it:
        MediaSession* mediaSession = MediaSession::createNew(*env,
sdpDescription);
        if (mediaSession == NULL) {
            printf("Failed to create mediaSession");
            break;
        }

        int audiofound = 0;
        // Create RTP receivers (sources) for each subsession:
        MediaSubsessionIterator iter(*mediaSession);
        MediaSubsession* subsession;
        unsigned desiredReceiveBufferSize;
        while ((subsession = iter.next()) != NULL)
        {
            // Ignore any subsession that's not audio or video:
            if (strcmp(subsession->mediumName(), "audio") == 0) {
                if (audiofound) {
                    printf("Additional subsession \"audio/%s\" skipped\n",
subsession->codecName());
                    continue;
                }
                desiredReceiveBufferSize = 100000;
            } else if (strcmp(subsession->mediumName(), "video") == 0) {
                desiredReceiveBufferSize = 2000000;
            } else {
                continue;
            }

            if (!subsession->initiate()) {
                printf( "Failed to initiate \"%s/%s\" RTP subsession: %s\n",
subsession->mediumName(), subsession->codecName(), env->getResultMsg());
            } else {
                printf( "Initiated \"%s/%s\" RTP subsession on port %d\n",
subsession->mediumName(), subsession->codecName(),
subsession->clientPortNum());

                // Set the OS's socket receive buffer sufficiently large to
avoid
                // incoming packets getting dropped between successive reads
from this
                // subsession's demuxer.  Depending on the bitrate(s) that
you expect,
                // you may wish to tweak the "desiredReceiveBufferSize"
values above.
                int rtpSocketNum =
subsession->rtpSource()->RTPgs()->socketNum();
                int receiveBufferSize = increaseReceiveBufferTo(*env,
rtpSocketNum,desiredReceiveBufferSize);

                printf("Increased %s socket receive buffer to %d bytes \n",
subsession->mediumName(), receiveBufferSize);

                if (rtspClient != NULL) {
                    // Issue a RTSP "SETUP" command on the chosen
subsession:
                    if (!rtspClient->setupMediaSubsession(*subsession,
False, rtspStreamOverTCP)) break;
                    if (!strcmp(subsession->mediumName(), "audio"))
                        audiofound = 1;
                }
            }
        }

        if (rtspClient != NULL) {
            // Issue a RTSP aggregate "PLAY" command on the whole session:
            if (!rtspClient->playMediaSession(*mediaSession)) {
                printf( "playMediaSession hata");
                break;
            }
        }

        // Now that the session is ready to be read, do additional
        // MPlayer codec-specific initialization on each subsession:
        iter.reset();
        while ((subsession = iter.next()) != NULL) {
            if (subsession->readSource() == NULL) continue; // not reading
this

            unsigned flags = 0;
            if (strcmp(subsession->mediumName(), "audio") == 0) {
                ???????
            } else if (strcmp(subsession->mediumName(), "video") == 0) {
               ???????
            }

        }
        success = True;


    } while (0);

     ???????

    return 0;
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.live555.com/pipermail/live-devel/attachments/20080531/97969341/attachment-0001.html>


More information about the live-devel mailing list