zyzhaojun / qtffmpegwrapper

Automatically exported from code.google.com/p/qtffmpegwrapper
Other
0 stars 0 forks source link

Program selection #12

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
Canot select a spécific program id.

What is the expected output? What do you see instead?
Implement a QVideoDecoder method :selectProgram(int programId)
which set the videoStream on programId stream_index.

What version of the product are you using? On what operating system?
version: 23 09 2011
os: win7

Please provide any additional information below.
   void QVideoDecoder::setProgram(int programId)
   {
        int index = -1;

        for(int i=0; i<this->pFormatCtx->nb_programs; i++)
        {
            ffmpeg::AVProgram *program = this->pFormatCtx->programs[i];
            if(program->id != programId)
                continue;
            for(int j=0; j<program->nb_stream_indexes; j++)
            {
                int sidx1 = program->stream_index[j];
                int sidx2 = *program->stream_index;
                int ris = sidx2 + j;

                ffmpeg::AVStream *avs = this->pFormatCtx->streams[ris];
                ffmpeg::AVDiscard avd = avs->discard;
                ffmpeg::AVCodecContext *avc = avs->codec;
                ///ffmpeg::CodecType typ = avc->codec_type;

                /*if(/*this->pFormatCtx->streams[ris]->discard
                        &&* this->pFormatCtx->streams[ris]->codec->codec_type == type)*/
                {
                    index = ris;
                    break;
                }
            }

            qDebug() << "QVideoDecoder.setProgram(): Program Index=" << program->id;
            //qDebug() << "QVideoDecoder.setProgram(): Program Index=" << program->provider_name;
            //qDebug() << "QVideoDecoder.setProgram(): Program Name=" << program->name;
            qDebug() << "QVideoDecoder.setProgram(): Program Index=" << index;

        }

        if (index != -1)
        {
            videoStream=index; // OCA

            // Get a pointer to the codec context for the video stream
            pCodecCtx=pFormatCtx->streams[videoStream]->codec;

            // Find the decoder for the video stream
            pCodec=avcodec_find_decoder(pCodecCtx->codec_id);

            if(pCodec!=NULL)
            {
                avcodec_open(pCodecCtx, pCodec);
            }
        }
  }

Original issue reported on code.google.com by camus.ol...@googlemail.com on 30 Nov 2011 at 9:03