Example #1
0
GstBusSyncReply
GStreamerReader::Error(GstBus *aBus, GstMessage *aMessage)
{
  if (GST_MESSAGE_TYPE(aMessage) == GST_MESSAGE_ERROR) {
    Eos();
  }

  return GST_BUS_PASS;
}
Example #2
0
void GStreamerReader::VideoPreroll()
{
  /* The first video buffer has reached the video sink. Get width and height */
  LOG(PR_LOG_DEBUG, "Video preroll");
  GstPad* sinkpad = gst_element_get_static_pad(GST_ELEMENT(mVideoAppSink), "sink");
  int PARNumerator, PARDenominator;
#if GST_VERSION_MAJOR >= 1
  GstCaps* caps = gst_pad_get_current_caps(sinkpad);
  memset (&mVideoInfo, 0, sizeof (mVideoInfo));
  gst_video_info_from_caps(&mVideoInfo, caps);
  mFormat = mVideoInfo.finfo->format;
  mPicture.width = mVideoInfo.width;
  mPicture.height = mVideoInfo.height;
  PARNumerator = GST_VIDEO_INFO_PAR_N(&mVideoInfo);
  PARDenominator = GST_VIDEO_INFO_PAR_D(&mVideoInfo);
#else
  GstCaps* caps = gst_pad_get_negotiated_caps(sinkpad);
  gst_video_format_parse_caps(caps, &mFormat, &mPicture.width, &mPicture.height);
  if (!gst_video_parse_caps_pixel_aspect_ratio(caps, &PARNumerator, &PARDenominator)) {
    PARNumerator = 1;
    PARDenominator = 1;
  }
#endif
  NS_ASSERTION(mPicture.width && mPicture.height, "invalid video resolution");

  // Calculate display size according to pixel aspect ratio.
  nsIntRect pictureRect(0, 0, mPicture.width, mPicture.height);
  nsIntSize frameSize = nsIntSize(mPicture.width, mPicture.height);
  nsIntSize displaySize = nsIntSize(mPicture.width, mPicture.height);
  ScaleDisplayByAspectRatio(displaySize, float(PARNumerator) / float(PARDenominator));

  // If video frame size is overflow, stop playing.
  if (IsValidVideoRegion(frameSize, pictureRect, displaySize)) {
    GstStructure* structure = gst_caps_get_structure(caps, 0);
    gst_structure_get_fraction(structure, "framerate", &fpsNum, &fpsDen);
    mInfo.mVideo.mDisplay = ThebesIntSize(displaySize.ToIntSize());
    mInfo.mVideo.mHasVideo = true;
  } else {
    LOG(PR_LOG_DEBUG, "invalid video region");
    Eos();
  }
  gst_caps_unref(caps);
  gst_object_unref(sinkpad);
}
Example #3
0
// ----------------------------------------------------------------------------
// TTunnelParser::NextToken
// Returns the next token type in the input stream. iToken gets the value of
// the (string) token.
// ----------------------------------------------------------------------------
//
TTunnelParser::TTokenType TTunnelParser::NextToken ()
{
    TChar ch;
    TTokenType val;

    SkipSpaceAndMark ();
    if (Eos ())
        val = ETokenTypeEof;
    else
    {
        ch = Get ();
        switch (ch)
        {
        case '{':
            val = ETokenTypeBraceLeft;
            break;
        case '}':
            val = ETokenTypeBraceRight;
            break;
        case '(':
            val = ETokenTypeParLeft;
            break;
        case ')':
            val = ETokenTypeParRight;
            break;
        case '=':
            val = ETokenTypeEqual;
            break;
        case ',':
            val = ETokenTypeComma;
            break;
        case '#':
            val = ETokenTypeComment;
            while (!Eos())
            {
                ch = Get();
                if (ch == '\n' || ch == '\r')
                    break;
            }
            break;
        default:
            // Integers, ip addresses, etc. are mapped to strings.
            val = ETokenTypeString;
            while (!Eos ())
            {
                ch = Peek ();
                if (ch == '{' || ch == '}' ||
                        ch == '(' || ch == ')' ||
                        ch == '=' || ch == '#' ||
                        ch == ',' || ch.IsSpace ())
                    break;
                Inc ();
            }
        }
    }

    iToken.Set (MarkedToken ());
    SkipSpaceAndMark ();

    return val;
}