~ubuntu-branches/ubuntu/natty/zoneminder/natty

« back to all changes in this revision

Viewing changes to src/zm_remote_camera_rtsp.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Peter Howard
  • Date: 2009-09-11 07:02:50 UTC
  • mfrom: (1.2.2 upstream)
  • mto: This revision was merged to the branch mainline in revision 10.
  • Revision ID: james.westby@ubuntu.com-20090911070250-k6rtdg43xi46nix4
Tags: 1.24.2-1
Initial release of zoneminder 1.24.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
//
2
 
// ZoneMinder Remote Camera Class Implementation, $Date: 2009-02-16 18:21:50 +0000 (Mon, 16 Feb 2009) $, $Revision: 2765 $
 
2
// ZoneMinder Remote Camera Class Implementation, $Date: 2009-06-03 09:10:28 +0100 (Wed, 03 Jun 2009) $, $Revision: 2907 $
3
3
// Copyright (C) 2001-2008 Philip Coombes
4
4
// 
5
5
// This program is free software; you can redistribute it and/or
28
28
#include <sys/types.h>
29
29
#include <sys/socket.h>
30
30
 
31
 
RemoteCameraRtsp::RemoteCameraRtsp( int p_id, const std::string &p_method, const std::string &p_host, const std::string &p_port, const std::string &p_path, const std::string &p_subpath, int p_width, int p_height, int p_colours, int p_brightness, int p_contrast, int p_hue, int p_colour, bool p_capture ) :
32
 
    RemoteCamera( p_id, "rtsp", p_host, p_port, p_path, p_subpath, p_width, p_height, p_colours, p_brightness, p_contrast, p_hue, p_colour, p_capture ),
 
31
RemoteCameraRtsp::RemoteCameraRtsp( int p_id, const std::string &p_method, const std::string &p_host, const std::string &p_port, const std::string &p_path, int p_width, int p_height, int p_colours, int p_brightness, int p_contrast, int p_hue, int p_colour, bool p_capture ) :
 
32
    RemoteCamera( p_id, "rtsp", p_host, p_port, p_path, p_width, p_height, p_colours, p_brightness, p_contrast, p_hue, p_colour, p_capture ),
33
33
    rtspThread( 0 )
34
34
{
35
35
    if ( p_method == "rtpUni" )
88
88
 
89
89
int RemoteCameraRtsp::Connect()
90
90
{
91
 
    rtspThread = new RtspThread( id, method, protocol, host, port, path, subpath, auth );
 
91
    rtspThread = new RtspThread( id, method, protocol, host, port, path, auth );
92
92
 
93
93
    rtspThread->start();
94
94
 
110
110
int RemoteCameraRtsp::PrimeCapture()
111
111
{
112
112
    Debug( 2, "Waiting for sources" );
113
 
    for ( int i = 0; i < 50 && !rtspThread->hasSources(); i++ )
 
113
    for ( int i = 0; i < 100 && !rtspThread->hasSources(); i++ )
114
114
    {
115
115
        usleep( 100000 );
116
116
    }
151
151
 
152
152
int RemoteCameraRtsp::PreCapture()
153
153
{
 
154
    if ( !rtspThread->isRunning() )
 
155
        return( -1 );
154
156
    if ( !rtspThread->hasSources() )
155
157
    {
156
158
        Error( "Cannot precapture, no RTP sources" );
164
166
    while ( true )
165
167
    {
166
168
        buffer.clear();
167
 
        if ( rtspThread->stopped() )
 
169
        if ( !rtspThread->isRunning() )
168
170
            break;
 
171
        //if ( rtspThread->stopped() )
 
172
            //break;
169
173
        if ( rtspThread->getFrame( buffer ) )
170
174
        {
171
175
            Debug( 3, "Read frame %d bytes", buffer.size() );
210
214
                        return( 0 );
211
215
                    }
212
216
                    Error( "Error while decoding frame %d", frameCount );
213
 
                    Hexdump( ZM_DBG_ERR, buffer.head(), buffer.size() );
214
 
                    return( -1 );
 
217
                    Hexdump( ZM_DBG_ERR, buffer.head(), buffer.size()>256?256:buffer.size() );
 
218
                    buffer.clear();
 
219
                    continue;
 
220
                    //return( -1 );
215
221
                }
216
 
                Debug( 2, "Frame: %d: %d/%d", frameCount, len, buffer.size() );
 
222
                Debug( 2, "Frame: %d - %d/%d", frameCount, len, buffer.size() );
217
223
                //if ( buffer.size() < 400 )
218
224
                    //Hexdump( 0, buffer.head(), buffer.size() );
219
225