コード例 #1
0
ファイル: format_ogg.c プロジェクト: Yahav/icecast-kh
static void ogg_apply_client (format_plugin_t *plugin, client_t *client)
{
    ogg_state_t *state = plugin->_state;

    state->mount = NULL;
    ogg_sync_clear (&state->oy);

    if (client == NULL)
        return;
    plugin->parser = client->parser;
    if (plugin->parser)
    {
        const char *s = httpp_getvar (plugin->parser, "content-type");
        if (s==NULL || strcmp (s, "application/x-ogg") == 0)
            httpp_setvar (plugin->parser, "content-type", "application/ogg");
        s = httpp_getvar (plugin->parser, "content-type");
        if (s)
            plugin->contenttype = strdup (s);
    }

    ogg_sync_init (&state->oy);

    state->mount = plugin->mount;
    state->bos_end = &state->header_pages;
}
コード例 #2
0
ファイル: framing.c プロジェクト: andreipaga/audacity
/* clear non-flat storage within */
int ogg_sync_clear(ogg_sync_state *oy){
  if(oy){
    if(oy->data)_ogg_free(oy->data);
    ogg_sync_init(oy);
  }
  return(0);
}
コード例 #3
0
ファイル: ripogg.c プロジェクト: hdijkema/libstreamripper
void rip_ogg_init(RIP_MANAGER_INFO * rmi)
{
	ogg_sync_init(&rmi->ogg_sync);
	memset(&rmi->stream, 0, sizeof(stream_processor));
	rmi->ogg_curr_header = 0;
	rmi->ogg_curr_header_len = 0;
}
コード例 #4
0
int format_ogg_get_plugin (format_plugin_t *plugin, client_t *client)
{
    ogg_state_t *state = calloc (1, sizeof (ogg_state_t));

    plugin->get_buffer = ogg_get_buffer;
    plugin->write_buf_to_client = write_buf_to_client;
    plugin->write_buf_to_file = write_ogg_to_file;
    plugin->create_client_data = create_ogg_client_data;
    plugin->free_plugin = format_ogg_free_plugin;
    plugin->get_image = get_image;
    plugin->set_tag = NULL;
    plugin->apply_settings = apply_ogg_settings;
    if (plugin->parser)
    {
        const char *s = httpp_getvar (plugin->parser, "content-type");;
        if (s==NULL || strcmp (s, "application/x-ogg") == 0)
            httpp_setvar (plugin->parser, "content-type", "application/ogg");
        plugin->contenttype = strdup (httpp_getvar (plugin->parser, "content-type"));
    }
    else
        plugin->contenttype = strdup ("application/ogg");

    ogg_sync_init (&state->oy);

    plugin->_state = state;
    state->mount = plugin->mount;
    state->bos_end = &state->header_pages;

    return 0;
}
コード例 #5
0
ファイル: ogg.c プロジェクト: KoetseJ/xumo
static int ogg_read_header(AVFormatContext *avfcontext, AVFormatParameters *ap)
{
    OggContext *context = avfcontext->priv_data;
    char *buf ;
    ogg_page og ;
    AVStream *ast ;
    
    ogg_sync_init(&context->oy) ;
    buf = ogg_sync_buffer(&context->oy, DECODER_BUFFER_SIZE) ;

    if(get_buffer(&avfcontext->pb, buf, DECODER_BUFFER_SIZE) <= 0)
	return -EIO ;
    
    ogg_sync_wrote(&context->oy, DECODER_BUFFER_SIZE) ;   
    ogg_sync_pageout(&context->oy, &og) ;
    ogg_stream_init(&context->os, ogg_page_serialno(&og)) ;
    ogg_stream_pagein(&context->os, &og) ;
  
    /* currently only one vorbis stream supported */

    ast = av_new_stream(avfcontext, 0) ;
    if(!ast)
	return AVERROR_NOMEM ;

    ast->codec.codec_type = CODEC_TYPE_AUDIO ;
    ast->codec.codec_id = CODEC_ID_VORBIS ;
    
    return 0 ;
}
コード例 #6
0
ファイル: ogg_vorbis.c プロジェクト: stohrendorf/libsndfile
static sf_count_t
vorbis_length_aux (SF_PRIVATE * psf)
{	ogg_sync_state osync ;
	ogg_page page ;
	sf_count_t len = 0 ;
	stream_set *processors ;

	processors = create_stream_set () ;
	if (processors == NULL)
		return 0 ;	// out of memory?

	ogg_sync_init (&osync) ;

	while (vorbis_length_get_next_page (psf, &osync, &page))
	{	stream_processor *p = find_stream_processor (processors, &page) ;

		if (!p)
		{	len = 0 ;
			break ;
		} ;

		if (p->isillegal && !p->shownillegal)
		{	p->shownillegal = 1 ;
			/* If it's a new stream, we want to continue processing this page
			** anyway to suppress additional spurious errors
			*/
			if (!p->isnew) continue ;
		} ;

		if (!p->isillegal)
		{	ogg_packet packet ;
			int header = 0 ;

			ogg_stream_pagein (&p->ostream, &page) ;
			if (p->doneheaders < 3)
				header = 1 ;

			while (ogg_stream_packetout (&p->ostream, &packet) > 0)
			{	if (p->doneheaders < 3)
				{	if (vorbis_synthesis_headerin (&p->vinfo, &p->vcomment, &packet) < 0)
						continue ;
					p->doneheaders ++ ;
				} ;
			} ;
			if (!header)
			{	sf_count_t gp = ogg_page_granulepos (&page) ;
				if (gp > 0) p->lastgranulepos = gp ;
			} ;
			if (p->end)
			{	vorbis_end (p, &len) ;
				p->isillegal = 1 ;
			} ;
		} ;
	} ;

	ogg_sync_clear (&osync) ;
	free_stream_set (processors, &len) ;

	return len ;
} /* vorbis_length_aux */
コード例 #7
0
ファイル: format_ogg.c プロジェクト: TeddyRilliot/icecast
int format_ogg_get_plugin (source_t *source)
{
    format_plugin_t *plugin;
    ogg_state_t *state = calloc (1, sizeof (ogg_state_t));

    plugin = (format_plugin_t *)calloc(1, sizeof(format_plugin_t));

    plugin->type = FORMAT_TYPE_OGG;
    plugin->get_buffer = ogg_get_buffer;
    plugin->write_buf_to_client = write_buf_to_client;
    plugin->write_buf_to_file = write_ogg_to_file;
    plugin->create_client_data = create_ogg_client_data;
    plugin->free_plugin = format_ogg_free_plugin;
    plugin->set_tag = NULL;
    if (strcmp (httpp_getvar (source->parser, "content-type"), "application/x-ogg") == 0)
        httpp_setvar (source->parser, "content-type", "application/ogg");
    plugin->contenttype = httpp_getvar (source->parser, "content-type");

    ogg_sync_init (&state->oy);

    plugin->_state = state;
    source->format = plugin;
    state->mount = source->mount;
    state->bos_end = &state->header_pages;

    return 0;
}
コード例 #8
0
ファイル: stream_decoder.c プロジェクト: Kirushanr/audacity
OggFLAC__StreamDecoderState OggFLAC__stream_decoder_init(OggFLAC__StreamDecoder *decoder)
{
	FLAC__ASSERT(0 != decoder);

	if(decoder->protected_->state != OggFLAC__STREAM_DECODER_UNINITIALIZED)
		return decoder->protected_->state = OggFLAC__STREAM_DECODER_ALREADY_INITIALIZED;

	if(0 == decoder->private_->read_callback || 0 == decoder->private_->write_callback || 0 == decoder->private_->metadata_callback || 0 == decoder->private_->error_callback)
		return decoder->protected_->state = OggFLAC__STREAM_DECODER_INVALID_CALLBACK;

	decoder->private_->ogg.need_serial_number = decoder->protected_->use_first_serial_number;
	/* we will determine the serial number later if necessary */
	if(ogg_stream_init(&decoder->private_->ogg.stream_state, decoder->protected_->serial_number) != 0)
		return decoder->protected_->state = OggFLAC__STREAM_DECODER_OGG_ERROR;

	if(ogg_sync_init(&decoder->private_->ogg.sync_state) != 0)
		return decoder->protected_->state = OggFLAC__STREAM_DECODER_OGG_ERROR;

	FLAC__stream_decoder_set_read_callback(decoder->private_->FLAC_stream_decoder, read_callback_);
	FLAC__stream_decoder_set_write_callback(decoder->private_->FLAC_stream_decoder, write_callback_);
	FLAC__stream_decoder_set_metadata_callback(decoder->private_->FLAC_stream_decoder, metadata_callback_);
	FLAC__stream_decoder_set_error_callback(decoder->private_->FLAC_stream_decoder, error_callback_);
	FLAC__stream_decoder_set_client_data(decoder->private_->FLAC_stream_decoder, decoder);

	if(FLAC__stream_decoder_init(decoder->private_->FLAC_stream_decoder) != FLAC__STREAM_DECODER_SEARCH_FOR_METADATA)
		return decoder->protected_->state = OggFLAC__STREAM_DECODER_FLAC_STREAM_DECODER_ERROR;

	return decoder->protected_->state = OggFLAC__STREAM_DECODER_OK;
}
コード例 #9
0
ファイル: speex.c プロジェクト: jonsafari/mocp
static struct spx_data *spx_open_internal (struct io_stream *stream)
{
	struct spx_data *data;
	SpeexStereoState stereo = SPEEX_STEREO_STATE_INIT;

	data = (struct spx_data *)xmalloc (sizeof(struct spx_data));

	decoder_error_init (&data->error);
	data->stream = stream;

	data->st = NULL;
	data->stereo = stereo;
	data->header = NULL;
	data->output = NULL;
	data->comment_packet = NULL;
	data->bitrate = -1;
	ogg_sync_init (&data->oy);
	speex_bits_init (&data->bits);

	if (!read_speex_header(data)) {
		ogg_sync_clear (&data->oy);
		speex_bits_destroy (&data->bits);
		data->ok = 0;
	}
	else
		data->ok = 1;

	return data;
}
コード例 #10
0
int format_ogg_get_plugin (source_t *source)
{
    format_plugin_t *plugin;
    ogg_state_t *state = calloc (1, sizeof (ogg_state_t));

    plugin = (format_plugin_t *)calloc(1, sizeof(format_plugin_t));

    plugin->type = FORMAT_TYPE_OGG;
    plugin->get_buffer = ogg_get_buffer;
    plugin->write_buf_to_client = write_buf_to_client;
    plugin->write_buf_to_file = write_ogg_to_file;
    plugin->create_client_data = create_ogg_client_data;
    plugin->client_send_headers = format_ogg_send_headers;
    plugin->free_plugin = format_ogg_free_plugin;
    plugin->set_tag = NULL;
    plugin->contenttype = "application/ogg";

    ogg_sync_init (&state->oy);

    plugin->_state = state;
    source->format = plugin;
    state->mount = source->mount;
    state->bos_end = &state->header_pages;

    return 0;
}
コード例 #11
0
ファイル: oggedit_flac.c プロジェクト: Gardenya/deadbeef
off_t oggedit_flac_stream_info(DB_FILE *in, const off_t start_offset, const off_t end_offset)
{
    ogg_sync_state oy;
    ogg_sync_init(&oy);
    const off_t stream_size = codec_stream_size(in, &oy, start_offset, end_offset, FLACNAME);
    cleanup(in, NULL, &oy, NULL);
    return stream_size;
}
コード例 #12
0
ファイル: OggReaderPlugin.cpp プロジェクト: mariuz/haiku
OggReader::OggReader()
{
	TRACE("OggReader::OggReader\n");
	ogg_sync_init(&fSync);
	fSeekable = NULL;
	fFile = NULL;
	fPosition = 0;
}
コード例 #13
0
ファイル: pyEx_ogg.c プロジェクト: vigith/ogg-theora-vorbis
static PyObject * py_ogg_ogg_sync_init(PyObject *self, PyObject *args) {
  int c_out;
  int size;
  ogg_sync_state * oy;
  PyArg_ParseTuple(args, "s#", &oy, &size);
  c_out = ogg_sync_init(oy);
  return Py_BuildValue("i", c_out);
};
コード例 #14
0
ファイル: decoding.c プロジェクト: Distrotech/libkate
int main()
{
  ogg_sync_state oy;
  ogg_stream_state os;
  int init=0;
  ogg_packet op;
  kate_state k;
  kate_info ki;
  kate_comment kc;
  const kate_event *ev;

  /* for the benefit of windows, which mangles data otherwise */
  set_binary_file(stdin);

  /* we initialize ogg and kate info/comment structures */
  ogg_sync_init(&oy);
  kate_info_init(&ki);
  kate_comment_init(&kc);

  /*
    First, read the headers, which must appear first in a Kate stream. When
    kate_decode_header returns a positive number, all headers have been seen
    and we're ready to decode data.
    */
  do {
    get_packet(&oy,&os,&init,&op);
  } while (kate_ogg_decode_headerin(&ki,&kc,&op)==0);

  /*
    We now have all the information we need from the headers, so we can
    initialize kate for decoding
    */
  kate_decode_init(&k,&ki);

  /*
    We can now read data, until kate_decode_packetin returns a positive
    number, signaling the end of the stream
    */
  while (1) {
    if (get_packet(&oy,&os,&init,&op)) break;
    if (kate_ogg_decode_packetin(&k,&op)>0) break;

    /* we may have an event (eg, text) */
    if (kate_decode_eventout(&k,&ev)==0) {
      printf("Kate stream has text: %s\n",ev->text);
    }
  }

  /* That's it, we can now cleanup */
  ogg_stream_clear(&os);
  ogg_sync_clear(&oy);

  kate_clear(&k);
  kate_info_clear(&ki);
  kate_comment_clear(&kc);

  return 0;
}
コード例 #15
0
ファイル: oggedit_vorbis.c プロジェクト: bro1/deadbeef
off_t oggedit_vorbis_stream_info(DB_FILE *in, const off_t start_offset, const off_t end_offset, char **codecs)
{
    ogg_sync_state oy;
    ogg_sync_init(&oy);
    *codecs = codec_names(in, &oy, start_offset);
    const off_t stream_size = codec_stream_size(in, &oy, start_offset, end_offset, VORBISNAME);
    cleanup(in, NULL, &oy, NULL);
    return stream_size;
}
コード例 #16
0
/*
 * Class:     org_tritonus_lowlevel_ogg_SyncState
 * Method:    init
 * Signature: ()V
 */
JNIEXPORT void JNICALL
Java_org_tritonus_lowlevel_ogg_SyncState_init
(JNIEnv* env, jobject obj)
{
	ogg_sync_state*	handle;

	if (debug_flag) { fprintf(debug_file, "Java_org_tritonus_lowlevel_ogg_SyncState_init(): begin\n"); }
	handle = getHandle(env, obj);
	ogg_sync_init(handle);
	if (debug_flag) { fprintf(debug_file, "Java_org_tritonus_lowlevel_ogg_SyncState_init(): end\n"); }
}
コード例 #17
0
ファイル: gsttarkindec.c プロジェクト: JJCG/gst-plugins-bad
static void
gst_tarkindec_setup (TarkinDec * tarkindec)
{
  tarkindec->tarkin_stream = tarkin_stream_new ();

  ogg_sync_init (&tarkindec->oy);
  ogg_stream_init (&tarkindec->os, 1);
  tarkin_info_init (&tarkindec->ti);
  tarkin_comment_init (&tarkindec->tc);

  tarkindec->setup = TRUE;
}
コード例 #18
0
ファイル: r_ogm.cpp プロジェクト: Azpidatziak/mkvtoolnix
void
ogm_reader_c::read_headers() {
  if (!ogm_reader_c::probe_file(m_in.get(), m_size))
    throw mtx::input::invalid_format_x();

  ogg_sync_init(&oy);

  show_demuxer_info();

  if (read_headers_internal() <= 0)
    throw mtx::input::header_parsing_x();
  handle_stream_comments();
}
コード例 #19
0
ファイル: ogg.c プロジェクト: achintsetia/ffmpeg0.4.9
static int ogg_read_header(AVFormatContext *avfcontext, AVFormatParameters *ap)
{
    OggContext *context = avfcontext->priv_data;
    ogg_packet op ;
    char *buf ;
    ogg_page og ;
    AVStream *ast ;
    AVCodecContext *codec;
    uint8_t *p;
    int i;

    ogg_sync_init(&context->oy) ;
    buf = ogg_sync_buffer(&context->oy, DECODER_BUFFER_SIZE) ;

    if(get_buffer(&avfcontext->pb, buf, DECODER_BUFFER_SIZE) <= 0)
        return AVERROR_IO ;

    ogg_sync_wrote(&context->oy, DECODER_BUFFER_SIZE) ;
    ogg_sync_pageout(&context->oy, &og) ;
    ogg_stream_init(&context->os, ogg_page_serialno(&og)) ;
    ogg_stream_pagein(&context->os, &og) ;

    /* currently only one vorbis stream supported */

    ast = av_new_stream(avfcontext, 0) ;
    if(!ast)
        return AVERROR_NOMEM ;
    av_set_pts_info(ast, 60, 1, AV_TIME_BASE);

    codec= &ast->codec;
    codec->codec_type = CODEC_TYPE_AUDIO;
    codec->codec_id = CODEC_ID_VORBIS;
    for(i=0; i<3; i++){
        if(next_packet(avfcontext, &op)){
            return -1;
        }
        if(op.bytes >= (1<<16) || op.bytes < 0)
            return -1;
        codec->extradata_size+= 2 + op.bytes;
        codec->extradata= av_realloc(codec->extradata, codec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE);
        memset(codec->extradata + codec->extradata_size, 0, FF_INPUT_BUFFER_PADDING_SIZE);
        p= codec->extradata + codec->extradata_size - 2 - op.bytes;
        *(p++)= op.bytes>>8;
        *(p++)= op.bytes&0xFF;
        memcpy(p, op.packet, op.bytes);
    }

    return 0 ;
}
コード例 #20
0
ファイル: vorbis.c プロジェクト: miksago/icecast
int shout_open_vorbis(shout_t *self)
{
	vorbis_data_t *vorbis_data;

	if (!(vorbis_data = (vorbis_data_t *)calloc(1, sizeof(vorbis_data_t))))
		return SHOUTERR_MALLOC;
	self->format_data = vorbis_data;

	ogg_sync_init(&vorbis_data->oy);

	self->send = send_vorbis;
	self->close = close_vorbis;

	return SHOUTERR_SUCCESS;
}
コード例 #21
0
ファイル: oggedit_opus.c プロジェクト: cboxdoerfer/deadbeef
off_t oggedit_write_opus_metadata(DB_FILE *in, const char *fname, const off_t offset, const off_t stream_size, const int output_gain, const uint32_t num_tags, char **tags)
{
    off_t res;
    char tempname[PATH_MAX] = "";
    char *vendor = NULL;
    ogg_sync_state oy;
    ogg_sync_init(&oy);

    /* Original file must be writable whichever way we update it */
    FILE *out = fopen(fname, "r+b");
    if (!out) {
        res = OGGEDIT_CANNOT_UPDATE_FILE;
        goto cleanup;
    }

    /* Should we write the tags packet directly into the existing file ... */
    const long tags_packet_size = check_opus_header(in, &oy, offset, &vendor);
    if (tags_packet_size <= OGGEDIT_EOF) {
        res = tags_packet_size;
        goto cleanup;
    }
    const int64_t metadata_size = strlen(TAGMAGIC) + vc_size(vendor, num_tags, tags);
    int64_t padding = tags_packet_size - metadata_size;
    const off_t file_size_k = in->vfs->getlength(in) / 1000;
    const off_t stream_size_k = stream_size ? stream_size / 1000 : file_size_k;
    if (file_size_k < 100 || padding < 0 || padding > file_size_k/10+stream_size_k+metadata_size) {
        res = open_temp_file(fname, tempname, &out);
        if (res) {
            goto cleanup;
        }
    }

    /* Re-pad if writing the whole file */
    if (*tempname)
        padding = stream_size_k < 90 ? 0 : stream_size_k < 1000 ? 128 : stream_size_k < 10000 ? 1024 : 8192;

    /* Write pages until we reach the correct OpusHead, then write OpusTags */
    ogg_page og;
    int64_t opus_serial = copy_up_to_codec(in, out, &oy, &og, *tempname ? 0 : offset, offset, OPUSNAME);
    if (opus_serial <= OGGEDIT_EOF) {
        res = opus_serial;
        goto cleanup;
    }
    if (output_gain > INT_MIN) {
        og.body[16] = output_gain & 0xFF;
        og.body[17] = output_gain >> 8 & 0xFF;
        ogg_page_checksum_set(&og);
    }
コード例 #22
0
ファイル: player_example.c プロジェクト: kbara/daala
int player_example_open_input(player_example *player, const char *path) {
  if ((player == NULL) || ((path == NULL) || (path[0] == '\0'))) return -1;
  if ((path[0] == '-') && (path[1] == '\0')) {
    player->input = stdin;
  }
  else {
    player->input = fopen(path, "rb");
  }
  if (player->input == NULL) {
    player->input_path = "";
    return -1;
  }
  player->input_path = path;
  ogg_sync_init(&player->oy);
  return 0;
}
コード例 #23
0
ファイル: oggeyman.cpp プロジェクト: ivanamihalek/oggeyman
bool Oggeyman::init(const char * path) {

	switch (video_format) {
	//pixel_format.set(r_offset,g_offset,b_offset,bpp not a_offset);
	case VF_RGB:
		pixel_format.set(0, 1, 2, 3);
		break;
	case VF_BGR:
		pixel_format.set(2, 1, 0, 3);
		break;
	case VF_RGBA:
		pixel_format.set(0, 1, 2, 4);
		break;
	case VF_BGRA:
		pixel_format.set(2, 1, 0, 4);
		break;
	}
	this->path = path;
	// open the input file
	infptr = fopen(path, "rb");
	if (!infptr) {
		printf("\t failure opening %s\n", path);
		return false;
	}
	// initialize  ogg and theora -- none of these have a useful diagnostics implemented
	ogg_sync_init(&overall_sync_state);
	theora_info_init(&theo_info);
	theora_comment_init(&theo_comment);
	// find theora stream
	if (!parse_headers())	return false;
	// bcs we are only interested in theora,
	// flip through pages until we are sure we are on theora page
	bool have_page = false;
	bool is_theora_page = false;
	do { // we start by checking the page that was read in during header perusal
		int retval = ogg_stream_pagein(&ogg_theora_stream_state, &current_ogg_page);
		is_theora_page = (retval >= 0);
		if (!is_theora_page) have_page = next_page();
	} while (have_page && !is_theora_page);
	// initialize theora decoder
	if (!initialize_theora())
		return false;
	// the user should allocate space for the output buffer, BGRAbuffer
	return true;
}
コード例 #24
0
static bool_t vorbis_check_fd (const char * filename, VFSFile * file)
{
    ogg_sync_state oy = {0};
    ogg_stream_state os = {0};
    ogg_page og = {0};
    ogg_packet op = {0};

    bool_t result = FALSE;

    ogg_sync_init (& oy);

    while (1)
    {
        int64_t bytes = ogg_sync_pageseek (& oy, & og);

        if (bytes < 0) /* skipped some bytes */
            continue;
        if (bytes > 0) /* got a page */
            break;

        void * buffer = ogg_sync_buffer (& oy, 2048);
        bytes = vfs_fread (buffer, 1, 2048, file);

        if (bytes <= 0)
            goto end;

        ogg_sync_wrote (& oy, bytes);
    }

    if (! ogg_page_bos (& og))
        goto end;

    ogg_stream_init (& os, ogg_page_serialno (& og));
    ogg_stream_pagein (& os, & og);

    if (ogg_stream_packetout (& os, & op) > 0 && vorbis_synthesis_idheader (& op))
        result = TRUE;

end:
    ogg_sync_clear (& oy);
    ogg_stream_clear (& os);

    return result;
}
コード例 #25
0
ファイル: ogg_decoder_aspect.c プロジェクト: kode54/flac
FLAC__bool FLAC__ogg_decoder_aspect_init(FLAC__OggDecoderAspect *aspect)
{
    /* we will determine the serial number later if necessary */
    if(ogg_stream_init(&aspect->stream_state, aspect->serial_number) != 0)
        return false;

    if(ogg_sync_init(&aspect->sync_state) != 0)
        return false;

    aspect->version_major = ~(0u);
    aspect->version_minor = ~(0u);

    aspect->need_serial_number = aspect->use_first_serial_number;

    aspect->end_of_stream = false;
    aspect->have_working_page = false;

    return true;
}
コード例 #26
0
ファイル: oggmux.c プロジェクト: ChinnaSuhas/ossbuild
static void
start_pipeline (GstElement * bin, GstPad * pad)
{
  GstStateChangeReturn ret;

  ogg_sync_init (&oggsync);

  eos_chain_states =
      g_hash_table_new_full (g_direct_hash, g_direct_equal, NULL, g_free);
  probe_id =
      gst_pad_add_buffer_probe (pad, G_CALLBACK (eos_buffer_probe), NULL);

  ret = gst_element_set_state (bin, GST_STATE_PLAYING);
  fail_if (ret == GST_STATE_CHANGE_FAILURE, "Could not start test pipeline");
  if (ret == GST_STATE_CHANGE_ASYNC) {
    ret = gst_element_get_state (bin, NULL, NULL, GST_CLOCK_TIME_NONE);
    fail_if (ret != GST_STATE_CHANGE_SUCCESS, "Could not start test pipeline");
  }
}
コード例 #27
0
/** The Initialization function 
  */
OMX_ERRORTYPE omx_vorbisdec_component_Init(OMX_COMPONENTTYPE *openmaxStandComp)  {
  omx_vorbisdec_component_PrivateType* omx_vorbisdec_component_Private = openmaxStandComp->pComponentPrivate;
  OMX_ERRORTYPE err = OMX_ErrorNone;
  OMX_U32 nBufferSize;

  /** Temporary First Output buffer size*/
  omx_vorbisdec_component_Private->inputCurrBuffer = NULL;
  omx_vorbisdec_component_Private->inputCurrLength = 0;
  nBufferSize = omx_vorbisdec_component_Private->ports[OMX_BASE_FILTER_OUTPUTPORT_INDEX]->sPortParam.nBufferSize * 2;
  omx_vorbisdec_component_Private->internalOutputBuffer = calloc(1,nBufferSize);
  omx_vorbisdec_component_Private->packetNumber = 0;
  omx_vorbisdec_component_Private->positionInOutBuf = 0;
  omx_vorbisdec_component_Private->isNewBuffer = 1;
  
  /** initializing vorbis decoder parameters */
  ogg_sync_init(&omx_vorbisdec_component_Private->oy);
  omx_vorbisdec_component_Private->convsize = 0;
                                                                                                                             
  return err;
};
コード例 #28
0
ファイル: gstoggaviparse.c プロジェクト: PeterXu/gst-mobile
static GstStateChangeReturn
gst_ogg_avi_parse_change_state (GstElement * element, GstStateChange transition)
{
  GstOggAviParse *ogg;
  GstStateChangeReturn result = GST_STATE_CHANGE_FAILURE;

  ogg = GST_OGG_AVI_PARSE (element);

  switch (transition) {
    case GST_STATE_CHANGE_NULL_TO_READY:
      ogg_sync_init (&ogg->sync);
      break;
    case GST_STATE_CHANGE_READY_TO_PAUSED:
      ogg_sync_reset (&ogg->sync);
      ogg_stream_reset (&ogg->stream);
      ogg->serial = -1;
      ogg->discont = TRUE;
      break;
    case GST_STATE_CHANGE_PAUSED_TO_PLAYING:
      break;
    default:
      break;
  }

  result = parent_class->change_state (element, transition);

  switch (transition) {
    case GST_STATE_CHANGE_PLAYING_TO_PAUSED:
      break;
    case GST_STATE_CHANGE_PAUSED_TO_READY:
      break;
    case GST_STATE_CHANGE_READY_TO_NULL:
      ogg_sync_clear (&ogg->sync);
      break;
    default:
      break;
  }
  return result;
}
コード例 #29
0
flac_header_extractor_c::flac_header_extractor_c(const std::string &file_name,
                                                 int64_t p_sid,
                                                 oggflac_mode_e p_mode)
  : metadata_parsed(false)
  , sid(p_sid)
  , num_packets(0)
  , num_header_packets(0)
  , done(false)
  , mode(p_mode)
{
  file    = new mm_file_io_c(file_name);
  decoder = FLAC__stream_decoder_new();

  if (!decoder)
    mxerror(Y("flac_header_extraction: FLAC__stream_decoder_new() failed.\n"));
  if (!FLAC__stream_decoder_set_metadata_respond_all(decoder))
    mxerror(Y("flac_header_extraction: Could not set metadata_respond_all.\n"));
  if (FLAC__stream_decoder_init_stream(decoder, fhe_read_cb, nullptr, nullptr, nullptr, nullptr, fhe_write_cb, fhe_metadata_cb, fhe_error_cb, this) != FLAC__STREAM_DECODER_INIT_STATUS_OK)
    mxerror(Y("flac_header_extraction: Could not initialize the FLAC decoder.\n"));

  ogg_sync_init(&oy);
}
コード例 #30
0
ファイル: vorbisfile.c プロジェクト: OS2World/LIB-SDL
static int _ov_open1(void *f,OggVorbis_File *vf,char *initial,
		     long ibytes, ov_callbacks callbacks){
  long offset=(f?callbacks.seek_func(f,0,SEEK_CUR):-1);
  int ret;

  memset(vf,0,sizeof(*vf));
  vf->datasource=f;
  vf->callbacks = callbacks;

  /* init the framing state */
  ogg_sync_init(&vf->oy);

  /* perhaps some data was previously read into a buffer for testing
     against other stream types.  Allow initialization from this
     previously read data (as we may be reading from a non-seekable
     stream) */
  if(initial){
    char *buffer=ogg_sync_buffer(&vf->oy,ibytes);
    memcpy(buffer,initial,ibytes);
    ogg_sync_wrote(&vf->oy,ibytes);
  }

  /* can we seek? Stevens suggests the seek test was portable */
  if(offset!=-1)vf->seekable=1;

  /* No seeking yet; Set up a 'single' (current) logical bitstream
     entry for partial open */
  vf->links=1;
  vf->vi=(vorbis_info *)_ogg_calloc(vf->links,sizeof(*vf->vi));
  vf->vc=(vorbis_comment *)_ogg_calloc(vf->links,sizeof(*vf->vc));
  
  /* Try to fetch the headers, maintaining all the storage */
  if((ret=_fetch_headers(vf,vf->vi,vf->vc,&vf->current_serialno,NULL))<0){
    vf->datasource=NULL;
    ov_clear(vf);
  }else if(vf->ready_state < PARTOPEN)
    vf->ready_state=PARTOPEN;
  return(ret);
}