bool LPCMStream::Probe(IBitStream &bs )
{
    char *last_dot = strrchr( bs.StreamName(), '.' );
    return 
        last_dot != NULL 
        && strcmp( last_dot+1, "lpcm") == 0;

}
Example #2
0
void MultiplexJob::SetupInputStreams( std::vector< IBitStream *> &inputs )
{
    IBitStream *bs;
    IBitStreamUndo undo;
    unsigned int i;
    bool bad_file = false;

    for( i = 0; i < inputs.size(); ++i )
    {
        bs = inputs[i];
        // Remember the streams initial state...
        bs->PrepareUndo( undo );
        if( LPCMStream::Probe( *bs ) )
        {
            mjpeg_info ("File %s looks like an LPCM Audio stream.",
                        bs->StreamName());
            bs->UndoChanges( undo );
            streams.push_back( new JobStream( bs,  LPCM_AUDIO) );
            ++audio_tracks;
            ++lpcm_tracks;
            continue;
        }

        bs->UndoChanges( undo );
        if( MPAStream::Probe( *bs ) )
        {
            mjpeg_info ("File %s looks like an MPEG Audio stream.",
                        bs->StreamName() );
            bs->UndoChanges( undo );
            streams.push_back( new JobStream( bs, MPEG_AUDIO) );
            ++audio_tracks;
            continue;
        }

        bs->UndoChanges( undo );
        if( AC3Stream::Probe( *bs ) )
        {
            mjpeg_info ("File %s looks like an AC3 Audio stream.",
                        bs->StreamName());
            bs->UndoChanges( undo );
            streams.push_back( new JobStream( bs, AC3_AUDIO) );
            ++audio_tracks;
            continue;
        }

        bs->UndoChanges( undo );
        if( DTSStream::Probe( *bs ) )
        {
            mjpeg_info ("File %s looks like a dts Audio stream.",
                        bs->StreamName());
            bs->UndoChanges( undo);
            streams.push_back( new JobStream( bs, DTS_AUDIO) );
            ++audio_tracks;
            continue;
        }

        bs->UndoChanges( undo );
        if( VideoStream::Probe( *bs ) )
        {
            mjpeg_info ("File %s looks like an MPEG Video stream.",
                        bs->StreamName());
            bs->UndoChanges( undo );
            streams.push_back( new JobStream( bs, MPEG_VIDEO) );
            ++video_tracks;
            continue;
        }

        bs->UndoChanges( undo );

        if( SUBPStream::Probe( *bs ) )
        {
            mjpeg_info ("File %s looks like an Subpicture stream.",
                        bs->StreamName());
            bs->UndoChanges( undo );
            streams.push_back( new JobStream( bs, SUBP_STREAM) );
            ++subtitle_tracks;
            continue;
        }


#ifdef ZALPHA
        if( ZAlphaStream::Probe( *bs ) )
        {
            mjpeg_info ("File %s looks like an Z/Alpha Video stream.",
                        bs->StreamName());
            bs->UndoChanges( undo );
            streams.push_back( new JobStream( bs, Z_ALPHA) );
            ++video_tracks;
            ++z_alpha_tracks;
            continue;
        }
#endif
        bad_file = true;
        mjpeg_error ("File %s unrecogniseable!", bs->StreamName());
        delete bs;
    }

    if( bad_file )
    {
        mjpeg_error_exit1( "Unrecogniseable file(s)... exiting.");
    }

    //
    // Where no parameters for streams have been specified
    // simply set the default values (these will depend on the format
    // we're muxing of course...)
    //

    for( i = video_param.size(); i < video_tracks; ++i )
    {
        video_param.push_back(VideoParams::Default( mux_format ));
    }
    for( i = lpcm_param.size(); i < lpcm_tracks; ++i )
    {
        lpcm_param.push_back(LpcmParams::Default(mux_format));
    }
    for( i = subtitle_params.size(); i < subtitle_tracks; ++i )
    {
        subtitle_params.push_back(SubtitleStreamParams::Default(mux_format));
    }


    //
    // Set standard values if the selected profile implies this...
    //
    for( i = 0; i <video_tracks; ++i )
    {
        if( video_param[i]->Force(mux_format) )
        {
            mjpeg_info( "Video stream %d: profile %d selected - ignoring non-standard options!", i, mux_format );
        }
    }

    mjpeg_info( "Found %d audio streams, %d video streams and %d subtitle streams",
                audio_tracks,
                video_tracks,
                subtitle_tracks
              );

}