/**@ingroup tmedia_consumer_group * Initialize the consumer. * @param self The consumer to initialize * @retval Zero if succeed and non-zero error code otherwise. * * @sa @ref tmedia_consumer_deinit */ int tmedia_consumer_init(tmedia_consumer_t* self) { if(!self){ TSK_DEBUG_ERROR("Invalid parameter"); return -1; } self->video.in.chroma = TMEDIA_CONSUMER_CHROMA_DEFAULT; self->video.display.chroma = TMEDIA_CONSUMER_CHROMA_DEFAULT; self->audio.bits_per_sample = TMEDIA_CONSUMER_BITS_PER_SAMPLE_DEFAULT; self->audio.ptime = tmedia_defaults_get_audio_ptime(); self->audio.volume = tmedia_defaults_get_volume(); return 0; }
/**@ingroup tmedia_codec_group * Initialize a Codec * @param self The codec to initialize. Could be any type of codec (e.g. @ref tmedia_codec_audio_t or @ref tmedia_codec_video_t). * @param type * @param name the name of the codec. e.g. "G.711u" or "G.711a" etc used in the sdp. * @param desc full description. * @param format the format. e.g. "0" for G.711.u or "8" for G.711a or "*" for MSRP. * @retval Zero if succeed and non-zero error code otherwise. */ int tmedia_codec_init(tmedia_codec_t* self, tmedia_type_t type, const char* name, const char* desc, const char* format) { if(!self || tsk_strnullORempty(name)) { TSK_DEBUG_ERROR("Invalid parameter"); return -1; } self->type = type; tsk_strupdate(&self->name, name); tsk_strupdate(&self->desc,desc); tsk_strupdate(&self->format, format); if(!self->bandwidth_max_upload) { self->bandwidth_max_upload = (type == tmedia_video ? tmedia_defaults_get_bandwidth_video_upload_max() : INT_MAX); // INT_MAX or <=0 means undefined } if(!self->bandwidth_max_download) { self->bandwidth_max_download = (type == tmedia_video ? tmedia_defaults_get_bandwidth_video_download_max() : INT_MAX); // INT_MAX or <=0 means undefined } if(!self->in.rate) { self->in.rate = self->plugin->rate; } if(!self->out.rate) { self->out.rate = self->plugin->rate; } if(type & tmedia_audio) { tmedia_codec_audio_t* audio = TMEDIA_CODEC_AUDIO(self); if(!audio->in.ptime) { audio->in.ptime = (self->plugin->audio.ptime ? self->plugin->audio.ptime : tmedia_defaults_get_audio_ptime()); } if(!audio->out.ptime) { audio->out.ptime = (self->plugin->audio.ptime ? self->plugin->audio.ptime : tmedia_defaults_get_audio_ptime()); } if(!audio->in.channels) { audio->in.channels = self->plugin->audio.channels; } if(!audio->out.channels) { audio->out.channels = self->plugin->audio.channels; } if(!audio->in.timestamp_multiplier) { audio->in.timestamp_multiplier = tmedia_codec_audio_get_timestamp_multiplier(self->id, self->in.rate); } if(!audio->out.timestamp_multiplier) { audio->out.timestamp_multiplier = tmedia_codec_audio_get_timestamp_multiplier(self->id, self->out.rate); } } // Video flipping: For backward compatibility we have to initialize the default values // according to the CFLAGS: 'FLIP_ENCODED_PICT' and 'FLIP_DECODED_PICT'. At any time you // can update thse values (e.g. when the device switch from landscape to portrait) using video_session->set(); else if(type & tmedia_video) { tmedia_codec_video_t* video = TMEDIA_CODEC_VIDEO(self); #if FLIP_ENCODED_PICT video->out.flip = tsk_true; #endif #if FLIP_DECODED_PICT video->in.flip = tsk_true; #endif if(!video->in.fps) { video->in.fps = self->plugin->video.fps ? self->plugin->video.fps : tmedia_defaults_get_video_fps(); } if(!video->out.fps) { video->out.fps = self->plugin->video.fps ? self->plugin->video.fps : tmedia_defaults_get_video_fps(); } if(video->in.chroma == tmedia_chroma_none) { video->in.chroma = tmedia_chroma_yuv420p; } if(video->out.chroma == tmedia_chroma_none) { video->out.chroma = tmedia_chroma_yuv420p; } if(0) { // @deprecated if(!video->in.width) { video->in.width = video->out.width = self->plugin->video.width; } if(!video->in.height) { video->in.height = video->out.height = self->plugin->video.height; } } else { int ret; unsigned width, height; video->pref_size = tmedia_defaults_get_pref_video_size(); if((ret = tmedia_video_get_size(video->pref_size, &width, &height)) != 0) { width = self->plugin->video.width; height = self->plugin->video.height; } if(!video->in.width) { video->in.width = video->out.width = width; } if(!video->in.height) { video->in.height = video->out.height = height; } } } return 0; }