Пример #1
0
void
CodecTest :: testGetSupportedVideoFramRates()
{
  codec = Codec::findEncodingCodecByName("mpeg2video");
  TSM_ASSERT("got codec", codec);
  int32_t numFrameRates = codec->getNumSupportedVideoFrameRates();
  TSM_ASSERT("should be more than one", numFrameRates > 0);
  for(int i = 0; i < numFrameRates; i++)
  {
    RefPointer<Rational> rate = codec->getSupportedVideoFrameRate(i);
    TSM_ASSERT("should be non null", rate);
    TSM_ASSERT("should be valid number", rate->getDouble());
  }
  TSM_ASSERT("should fail quietly",
      0 == codec->getSupportedVideoFrameRate(-1));
  TSM_ASSERT("should fail quietly",
      0 == codec->getSupportedVideoFrameRate(0x7FFFFFFF));
  
}
Пример #2
0
void
StreamCoderTest :: testGetters()
{
  int refcount=0;
  h->setupReading(h->SAMPLE_FILE);

  for(int i = 0; i< h->num_streams; i++)
  {
    RefPointer<IStream> stream;
    RefPointer<ICodec> codec;
    RefPointer<IRational> rational;
    stream = h->streams[i];
    coder = h->coders[i];

    VS_TUT_ENSURE_EQUALS("invalid direction", coder->getDirection(),
        IStreamCoder::DECODING);

    codec = coder->getCodec();
    refcount = codec->getCurrentRefCount();
    {
      LoggerStack stack;
      stack.setGlobalLevel(Logger::LEVEL_ERROR, false);
      coder->setCodec(codec.value());
    }
    // ensure that one release and one acquire happens
    VS_TUT_ENSURE_EQUALS("invalid releasing or acquiring of codec",
        codec->getCurrentRefCount(),
        refcount);

    VS_TUT_ENSURE_EQUALS("wrong codec type",
        codec->getType(),
        h->expected_codec_types[i]);
    VS_TUT_ENSURE_EQUALS("wrong codec id",
        codec->getID(),
        h->expected_codec_ids[i]);

    if (codec->getType() == ICodec::CODEC_TYPE_AUDIO)
    {
      if (h->expected_sample_rate)
        VS_TUT_ENSURE_EQUALS("unexpected sample rate",
            coder->getSampleRate(),
            h->expected_sample_rate
        );
      if (h->expected_channels)
        VS_TUT_ENSURE_EQUALS("unexpected sample rate",
            coder->getChannels(),
            h->expected_channels
        );

    } else if (codec->getType() == ICodec::CODEC_TYPE_VIDEO)
    {
      if (h->expected_width)
        VS_TUT_ENSURE_EQUALS("unexpected width",
            coder->getWidth(),
            h->expected_width
        );
      if (h->expected_height)
              VS_TUT_ENSURE_EQUALS("unexpected height",
                  coder->getHeight(),
                  h->expected_height
              );
      if (h->expected_gops)
        VS_TUT_ENSURE_EQUALS("unexpected group of pictures",
            coder->getNumPicturesInGroupOfPictures(),
            h->expected_gops
        );
      if (h->expected_pixel_format != IPixelFormat::NONE)
        VS_TUT_ENSURE_EQUALS("unexpected group of pictures",
            coder->getPixelType(),
            h->expected_pixel_format
        );
      if (h->expected_time_base)
      {
        rational = coder->getTimeBase();
        VS_TUT_ENSURE_DISTANCE("unexpected time base",
            rational->getDouble(),
            h->expected_time_base,
            0.0001
        );
        rational = stream->getTimeBase();
        VS_TUT_ENSURE_DISTANCE("unexpected time base",
            rational->getDouble(),
            h->expected_time_base,
            0.0001
        );

      }
    }
    else
    {
      VS_LOG_ERROR("Unexpected type of codec");
      TS_ASSERT(false);
    }
  }
}