Пример #1
0
static int
oggz_metric_update (OGGZ * oggz, long serialno)
{
  oggz_stream_t * stream;

  if (oggz == NULL) return OGGZ_ERR_BAD_OGGZ;

  stream = oggz_get_stream (oggz, serialno);
  if (stream == NULL) return OGGZ_ERR_BAD_SERIALNO;

  /* we divide by the granulerate, ie. mult by gr_d/gr_n, so ensure
   * numerator is non-zero */
  if (stream->granulerate_n == 0) {
    stream->granulerate_n= 1;
    stream->granulerate_d = 0;
  }

  if (stream->granuleshift == 0) {
    return oggz_set_metric_internal (oggz, serialno,
				     oggz_metric_default_linear,
				     NULL, 1);
  } else if (oggz_stream_get_content (oggz, serialno) == OGGZ_CONTENT_DIRAC) {
    return oggz_set_metric_internal (oggz, serialno,
				     oggz_metric_dirac,
				     NULL, 1);
  } else if (oggz_stream_get_content (oggz, serialno) == OGGZ_CONTENT_VP8) {
    return oggz_set_metric_internal (oggz, serialno,
				     oggz_metric_vp8,
				     NULL, 1);
  } else {
    return oggz_set_metric_internal (oggz, serialno,
				     oggz_metric_default_granuleshift,
				     NULL, 1);
  }
}
Пример #2
0
static int processBegin(oggz_packet *packet, long serialno)
{
	int bos = (packet->op.b_o_s != 0);
    //int bos = oggz_get_bos(oggz, serialno);
    //int bos = (packet->op.packetno == 0);
    if (!bos) {
        // Not a bitstream start -- move on to header decoding...
		if (skeletonStream) {
	        appState = STATE_SKELETON;
	        return processSkeleton(packet, serialno);
	    } else {
			appState = STATE_DECODING;
			ogvjs_callback_loaded_metadata(videoCodecName, audioCodecName);
	        return processDecoding(packet, serialno);
		}
    }

    OggzStreamContent content = oggz_stream_get_content(oggz, serialno);

    if (!videoStream && content == OGGZ_CONTENT_THEORA) {
        videoCodec = content;
        videoCodecName = "theora";
        videoStream = serialno;
        ogvjs_callback_video_packet((const char *)packet->op.packet, packet->op.bytes, -1, -1);
        return OGGZ_CONTINUE;
    }

    if (!audioStream && content == OGGZ_CONTENT_VORBIS) {
        audioCodec = content;
        audioCodecName = "vorbis";
        audioStream = serialno;
        ogvjs_callback_audio_packet((const char *)packet->op.packet, packet->op.bytes, -1);
        return OGGZ_CONTINUE;
    }

    if (!audioStream && content == OGGZ_CONTENT_OPUS) {
        audioCodec = content;
        audioCodecName = "opus";
        audioStream = serialno;
        ogvjs_callback_audio_packet((const char *)packet->op.packet, packet->op.bytes, -1);
        return OGGZ_CONTINUE;
    }

    if (!skeletonStream && content == OGGZ_CONTENT_SKELETON) {
        skeletonStream = serialno;

        int ret = oggskel_decode_header(skeleton, &packet->op);
        if (ret == 0) {
            skeletonHeadersComplete = 1;
        } else if (ret > 0) {
            // Just keep going
        } else {
            printf("Invalid ogg skeleton track data? %d\n", ret);
            return OGGZ_STOP_ERR;
        }
    }
    return OGGZ_CONTINUE;
}
Пример #3
0
/* In Flac, OggPCM, Speex, Theora and Vorbis the comment packet will
   be second in the stream, i.e. packetno=1, and it will have granulepos=0 */
ogg_packet *
oggz_comments_generate(OGGZ * oggz, long serialno,
                       int FLAC_final_metadata_block)
{
    OggzStreamContent packet_type;

    packet_type = oggz_stream_get_content (oggz, serialno);

    return oggz_comment_generate (oggz, serialno, packet_type,
                                  FLAC_final_metadata_block);
}
Пример #4
0
static void
print_codec_name (oggdmux_prc_t * ap_prc, long serialno)
{
  if (ap_prc)
    {
      OggzStreamContent content
        = oggz_stream_get_content (ap_prc->p_oggz_, serialno);
      const char * p_codec_name = oggz_content_type (content);
      TIZ_TRACE (handleOf (ap_prc), "%010lu: codec [%s]", serialno,
                 p_codec_name != NULL ? p_codec_name : "Unknown");
    }
}
Пример #5
0
static ogg_int64_t
gp_to_granule (OGGZ * oggz, long serialno, ogg_int64_t granulepos)
{
  int granuleshift;
  ogg_int64_t iframe, pframe, granule;
  OggzStreamContent content;

  granuleshift = oggz_get_granuleshift (oggz, serialno);
  content = oggz_stream_get_content (oggz, serialno);

  if (content == OGGZ_CONTENT_VP8) {
    granule = granulepos >> granuleshift;
  } else {
Пример #6
0
static int
read_audio_packet (OGGZ * ap_oggz, oggz_packet * ap_zp, long serialno,
                   void * ap_user_data)
{
  oggdmux_prc_t * p_prc = ap_user_data;
  int rc = OGGZ_CONTINUE;
  assert (ap_user_data);

  if (!p_prc->aud_port_disabled_
      && is_audio_content (oggz_stream_get_content (p_prc->p_oggz_, serialno)))
    {
      rc = read_packet (ap_oggz, ap_zp, serialno, ap_user_data,
                        ARATELIA_OGG_DEMUXER_AUDIO_PORT_BASE_INDEX);
    }
  TIZ_TRACE (handleOf (p_prc), "%010lu: rc [%d]", serialno, rc);
  return rc;
}
Пример #7
0
static OMX_ERRORTYPE
set_read_packet_callbacks (oggdmux_prc_t * ap_prc)
{
  OMX_ERRORTYPE rc = OMX_ErrorNone;
  long serialno = 0;
  int n = 0;
  int i = 0;
  void * p_nth_data = NULL;

  assert (ap_prc);

  n = oggz_table_size (ap_prc->p_tracks_);
  TIZ_TRACE (handleOf (ap_prc), "oggz table size [%d]", n);
  for (i = 0; i < n; i++)
    {
      OggzStreamContent content = OGGZ_CONTENT_UNKNOWN;
      p_nth_data = oggz_table_nth (ap_prc->p_tracks_, i, &serialno);
      assert (p_nth_data);
      print_codec_name (ap_prc, serialno);
      content = oggz_stream_get_content (ap_prc->p_oggz_, serialno);
      if (is_audio_content (content))
        {
          TIZ_TRACE (handleOf (ap_prc), "Set read_audio_packet callback");
          tiz_check_omx (
            set_read_packet_callback (ap_prc, serialno, read_audio_packet));
        }

      if (is_video_content (content))
        {
          TIZ_TRACE (handleOf (ap_prc), "Set read_video_packet callback");
          tiz_check_omx (
            set_read_packet_callback (ap_prc, serialno, read_video_packet));
        }
    }

  if (0 == n)
    {
      rc = OMX_ErrorFormatNotDetected;
    }

  return rc;
}