示例#1
0
static int processSkeleton(oggz_packet *packet, long serialno)
{
	float timestamp = oggz_tell_units(oggz) / 1000.0;
	float keyframeTimestamp = calc_keyframe_timestamp(packet, serialno);

    if (skeletonStream == serialno) {
        int ret = oggskel_decode_header(skeleton, &packet->op);
        if (ret < 0) {
            printf("Error processing skeleton packet: %d\n", ret);
            return OGGZ_STOP_ERR;
        }
        if (packet->op.e_o_s) {
            skeletonHeadersComplete = 1;
			appState = STATE_DECODING;
			ogvjs_callback_loaded_metadata(videoCodecName, audioCodecName);
        }
    }

    if (serialno == videoStream) {
    	ogvjs_callback_video_packet((const char *)packet->op.packet, packet->op.bytes, timestamp, keyframeTimestamp);
    }

    if (serialno == audioStream) {
    	ogvjs_callback_audio_packet((const char *)packet->op.packet, packet->op.bytes, timestamp);
    }

	return OGGZ_CONTINUE;
}
示例#2
0
static int processDecoding(oggz_packet *packet, long serialno) {
	float timestamp = oggz_tell_units(oggz) / 1000.0;
	float keyframeTimestamp = calc_keyframe_timestamp(packet, serialno);

    if (serialno == videoStream) {
    	ogvjs_callback_video_packet((const char *)packet->op.packet, packet->op.bytes, timestamp, keyframeTimestamp);
		return OGGZ_STOP_OK;
    }

    if (serialno == audioStream) {
    	ogvjs_callback_audio_packet((const char *)packet->op.packet, packet->op.bytes, timestamp);
		return OGGZ_STOP_OK;
    }

	return OGGZ_CONTINUE;
}
示例#3
0
int
main (int argc, char ** argv)
{
  FILE * f;
  OGGZ * oggz;
  long n;
  ogg_int64_t units;

  if (argc < 2) {
    printf ("usage: %s filename\n", argv[0]);
  }

  if ((f = fopen ((char *)argv[1], "rb")) == NULL) {
    printf ("unable to open file %s\n", argv[1]);
    exit (1);
  }

  if ((oggz = oggz_new (OGGZ_READ | OGGZ_AUTO)) == NULL) {
    printf ("unable to create oggz\n");
    exit (1);
  }

  oggz_io_set_read (oggz, my_io_read, f);
  oggz_io_set_seek (oggz, my_io_seek, f);
  oggz_io_set_tell (oggz, my_io_tell, f);

  oggz_set_read_callback (oggz, -1, read_packet, NULL);

  while ((n = oggz_read (oggz, 1024)) > 0);

  units = oggz_tell_units (oggz);
  printf ("Total length: %" PRId64 " ms\n", units);

  oggz_seek_units (oggz, units/2, SEEK_SET);

  printf ("seeked to byte offset %" PRId64 "\n", oggz_tell (oggz));

  while ((n = oggz_read (oggz, 1024)) > 0);

  oggz_close (oggz);

  exit (0);
}