Пример #1
0
static int
fs_encdec_delete (FS_DecEnc * ed)
{
  int i;

  if (!ed) return -1;

  free (ed->infilename);
  free (ed->outfilename);

  oggz_close (ed->oggz_in);
  oggz_close (ed->oggz_out);

  fish_sound_delete (ed->encoder);
  fish_sound_delete (ed->decoder);

  if (!ed->interleave) {
    for (i = 0; i < ed->channels; i++)
      free (ed->pcm[i]);
  }
  free (ed->pcm);
  
  free (ed);

  return 0;
}
Пример #2
0
int
main (int argc, char * argv[])
{
  OGGZ * reader, * writer;
  unsigned char data_buf[DATA_BUF_LEN];
  long n;

  INFO ("Testing override of IO seeking");

  writer = oggz_new (OGGZ_WRITE);
  if (writer == NULL)
    FAIL("newly created OGGZ writer == NULL");

  serialno = oggz_serialno_new (writer);

  if (oggz_write_set_hungry_callback (writer, hungry, 1, NULL) == -1)
    FAIL("Could not set hungry callback");

  reader = oggz_new (OGGZ_READ);
  if (reader == NULL)
    FAIL("newly created OGGZ reader == NULL");

  oggz_io_set_read (reader, my_io_read, data_buf);
  oggz_io_set_seek (reader, my_io_seek, data_buf);
  oggz_io_set_tell (reader, my_io_tell, data_buf);

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

  n = oggz_write_output (writer, data_buf, DATA_BUF_LEN);

  if (n >= DATA_BUF_LEN)
    FAIL("Too much data generated by writer");

  offset_end = n;

  oggz_read (reader, n);

  if (read_called == 0)
    FAIL("Read method ignored");

  if (oggz_seek (reader, 0, SEEK_SET) != 0)
    FAIL("Seek failure");

  read_called = 0;

  oggz_read (reader, n);

  if (read_called == 0)
    FAIL("Read method ignored after seeking");

  if (oggz_close (reader) != 0)
    FAIL("Could not close OGGZ reader");

  if (oggz_close (writer) != 0)
    FAIL("Could not close OGGZ writer");

  exit (0);
}
Пример #3
0
int
main (int argc, char * argv[])
{
  OGGZ * reader, * writer;
  unsigned char buf[READ_SIZE];
  long n, remaining, err;

  INFO ("Testing ability to pause while reading (OGGZ_STOP_OK)");

  writer = oggz_new (OGGZ_WRITE);
  if (writer == NULL)
    FAIL("newly created OGGZ writer == NULL");

  serialno = oggz_serialno_new (writer);

  if (oggz_write_set_hungry_callback (writer, hungry, 1, NULL) == -1)
    FAIL("Could not set hungry callback");

  reader = oggz_new (OGGZ_READ);
  if (reader == NULL)
    FAIL("newly created OGGZ reader == NULL");

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

  while ((remaining = oggz_write_output (writer, buf, READ_SIZE)) > 0) {
    n = oggz_read_input (reader, buf, remaining);

    if (n == OGGZ_ERR_READ_STOP_OK) {
      INFO ("+ Interrupted read detected");
    } else {
      remaining -= n;

      err = oggz_read_input (reader, buf+n, remaining);
      if (err == OGGZ_ERR_READ_STOP_OK) {
	INFO ("+ Interrupted read detected");
      } else {
	FAIL ("Interrupted read not reported");
      }
    }

    n = oggz_read_input (reader, buf+n, remaining);
    remaining -= n;
  }

  if (oggz_close (reader) != 0)
    FAIL("Could not close OGGZ reader");

  if (oggz_close (writer) != 0)
    FAIL("Could not close OGGZ writer");

  exit (0);
}
Пример #4
0
int play (char * file, char ** opts) {
 OGGZ * oggz;
 struct roarfish_play_inst inst;

 inst.roarfh = -1;
 inst.begun  = 0;

 inst.fsound = fish_sound_new(FISH_SOUND_DECODE, &inst.fsinfo);
 fish_sound_set_interleave(inst.fsound, 1);

 fish_sound_set_decoded_float_ilv(inst.fsound, decoded_float, (void*)&inst);

 if ((oggz = oggz_open(file, OGGZ_READ)) == NULL) {
  ROAR_ERR("Can not open input file: %s", file);
  return -1;
 }

 oggz_set_read_callback(oggz, -1, read_packet, inst.fsound);

 // TODO: add some status display here?
 while (oggz_read(oggz, 1024));

 oggz_close(oggz);

 fish_sound_delete(inst.fsound);

 return -1;
}
Пример #5
0
int
main (int argc, char ** argv)
{
  OGGZ * oggz;
  OggzTable * tracks;
  long n;

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

  tracks = oggz_table_new ();

  if ((oggz = oggz_open ((char *)argv[1], OGGZ_READ | OGGZ_AUTO)) == NULL) {
    printf ("unable to open file %s\n", argv[1]);
    exit (1);
  }

  oggz_set_read_page (oggz, -1, read_page, tracks);

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

  oggz_close (oggz);

  oggz_table_delete (tracks);

  exit (0);
}
Пример #6
0
void load_ogg_file(const char *filename)
{
	OGGZ *oggz;

	oggz = oggz_open(filename, OGGZ_READ | OGGZ_AUTO);
	if ( oggz == NULL )
	{
		mylog("Error opening ogg file\n");
	}
	mylog("Successfully opened ogg file %s\n", filename);

	// Initialize internal streams
	audio_stream = calloc(1, sizeof(struct ogg_stream));
	video_stream = calloc(1, sizeof(struct ogg_stream));

	oggz_set_read_callback(oggz, -1, read_cb, NULL);
	oggz_set_read_page(oggz, -1, read_page_cb, NULL);

	oggz_run(oggz);

	//mylog("Audio stream, serialno=%d\n", audio_stream->serialno);
	//dump_stream(audio_stream);
	//mylog("Video stream, serialno=%d\n", video_stream->serialno);
	//dump_stream(video_stream);

	oggz_close(oggz);
}
Пример #7
0
void
speex_dec_close(decoder_t * dec) {

	speex_pdata_t * pd = (speex_pdata_t *)dec->pdata;

	oggz_close(pd->oggz);
	speex_bits_destroy(&(pd->bits));
        speex_decoder_destroy(pd->decoder);
	rb_free(pd->rb);
}
Пример #8
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);
}
Пример #9
0
int
main (int argc, char ** argv)
{
  OGGZ * oggz;

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

  if ((oggz = oggz_open ((char *)argv[1], OGGZ_READ | OGGZ_AUTO)) == NULL) {
    printf ("unable to open file %s\n", argv[1]);
    exit (1);
  }

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

  oggz_run (oggz);

  oggz_close (oggz);

  exit (0);
}
int
main (int argc, char * argv[])
{
  OGGZ * oggz;
  unsigned char buf[1];
  long n;

  oggz = oggz_new (OGGZ_WRITE);
  if (oggz == NULL)
    FAIL("newly created OGGZ == NULL");

  serialno = oggz_serialno_new (oggz);

  if (oggz_write_set_hungry_callback (oggz, hungry, 1, NULL) == -1)
    FAIL("Could not set hungry callback");

  while ((n = oggz_write_output (oggz, buf, 1)) > 0);

  if (oggz_close (oggz) != 0)
    FAIL("Could not close OGGZ");

  exit (0);
}
Пример #11
0
void ogv_demuxer_destroy() {
	oggskel_destroy(skeleton);
    oggz_close(oggz);
	bq_free(bufferQueue);
	bufferQueue = NULL;
}
Пример #12
0
int
speex_dec_open(decoder_t * dec, char * filename) {

	speex_pdata_t * pd = (speex_pdata_t *)dec->pdata;
	file_decoder_t * fdec = dec->fdec;

	int enh = 1;
	char ogg_sig[4];
	long length_in_bytes = 0;
	long length_in_samples = 0;


	if ((pd->speex_file = fopen(filename, "rb")) == NULL) {
		fprintf(stderr, "speex_decoder_open: fopen() failed\n");
		return DECODER_OPEN_FERROR;
	}

	if (fread(ogg_sig, 1, 4, pd->speex_file) != 4) {
		fprintf(stderr, "couldn't read OGG signature from %s\n", filename);
		return DECODER_OPEN_FERROR;
	}

	if ((ogg_sig[0] != 'O') ||
	    (ogg_sig[1] != 'g') ||
	    (ogg_sig[2] != 'g') ||
	    (ogg_sig[3] != 'S')) {
		/* not an OGG stream */
		fclose(pd->speex_file);
		return DECODER_OPEN_BADLIB;
	}

        if ((pd->oggz = oggz_open(filename, OGGZ_READ | OGGZ_AUTO)) == NULL) {
                printf("nonexistent or unaccessible file %s\n", filename);
                return DECODER_OPEN_FERROR;
        }

        oggz_set_read_callback(pd->oggz, -1, read_ogg_packet, dec);

	pd->packetno = 0;
	pd->exploring = 1;
	pd->error = 0;
	while (pd->packetno < 2) { /* process Speex header and comments */
		oggz_read(pd->oggz, 1024);
	}

	if (pd->error != 0) {
		printf("Error opening Speex\n");
		oggz_close(pd->oggz);
		return DECODER_OPEN_BADLIB;
	}

	/* parse ogg packets till eof to get the last granulepos */
	while (oggz_read(pd->oggz, 1024) > 0)
		;

	length_in_bytes = oggz_tell(pd->oggz);

	oggz_close(pd->oggz);
	speex_bits_destroy(&(pd->bits));
        speex_decoder_destroy(pd->decoder);
	
	if ((pd->channels != 1) && (pd->channels != 2)) {
		printf("Sorry, Ogg Speex with %d channels is unsupported\n", pd->channels);
		return DECODER_OPEN_FERROR;
	}
	
	pd->packetno = 0;
	pd->exploring = 0;
	pd->error = 0;
        pd->oggz = oggz_open(filename, OGGZ_READ | OGGZ_AUTO);
	oggz_set_read_callback(pd->oggz, -1, read_ogg_packet, dec);
	speex_bits_init(&(pd->bits));
	pd->decoder = speex_decoder_init(pd->mode);
	speex_decoder_ctl(pd->decoder, SPEEX_SET_ENH, &enh);

	pd->is_eos = 0;
	pd->rb = rb_create(pd->channels * sample_size * RB_SPEEX_SIZE);
	fdec->fileinfo.channels = pd->channels;
	fdec->fileinfo.sample_rate = pd->sample_rate;
	length_in_samples = pd->granulepos + pd->nframes - 1;
	fdec->fileinfo.total_samples = length_in_samples;
	fdec->fileinfo.bps = 8 * length_in_bytes / (length_in_samples / pd->sample_rate);

	fdec->file_lib = SPEEX_LIB;
	strcpy(dec->format_str, "Ogg Speex");

	return DECODER_OPEN_SUCCESS;
}
Пример #13
0
    ~D() {
	if (m_fishSound) fish_sound_delete(m_fishSound);
	if (m_oggz) oggz_close(m_oggz);
        delete m_buffer;
    }