#define INI_ITEM_GENERAL_DOT_GENERATE "general:generate dot"
#define INI_ITEM_GENERAL_GST_ARGS "general:gstreamer arguments"
#define INI_ITEM_GENERAL_GST_EXCLUDED_ELEMENTS "general:gstreamer excluded elements"
+#define INI_ITEM_MEDIA_SOURCE_V_FORMAT "media source:video format"
+#define INI_ITEM_MEDIA_SOURCE_V_WIDTH "media source:video width"
+#define INI_ITEM_MEDIA_SOURCE_V_HEIGHT "media source:video height"
+#define INI_ITEM_MEDIA_SOURCE_V_FRAMERATE "media source:video framerate"
+#define INI_ITEM_MEDIA_SOURCE_A_FORMAT "media source:audio format"
+#define INI_ITEM_MEDIA_SOURCE_A_SAMPLERATE "media source:audio samplerate"
+#define INI_ITEM_MEDIA_SOURCE_A_CHANNELS "media source:audio channels"
+#define INI_ITEM_CODEC_VIDEO "codec:video codec"
+#define INI_ITEM_CODEC_AUDIO "codec:audio codec"
+
+#define DEFAULT_VIDEO_RAW_FORMAT "I420"
+#define DEFAULT_VIDEO_WIDTH 320
+#define DEFAULT_VIDEO_HEIGHT 240
+#define DEFAULT_VIDEO_FRAMERATE 30
+#define DEFAULT_AUDIO_RAW_FORMAT "S16LE"
+#define DEFAULT_AUDIO_SAMPLERATE 8000
+#define DEFAULT_AUDIO_CHANNELS 1
+
+#define DEFAULT_VIDEO_CODEC "vp8"
+#define DEFAULT_AUDIO_CODEC "opus"
+
+typedef enum {
+ INI_ITEM_TYPE_BOOL,
+ INI_ITEM_TYPE_INT,
+ INI_ITEM_TYPE_STRING,
+ INI_ITEM_TYPE_STRINGS
+} ini_item_type_e;
+
+static void __dump_item(const char *prefix_str, ini_item_type_e type, void *item)
+{
+ RET_IF(prefix_str == NULL, "prefix_str is NULL");
+
+ if (item == NULL)
+ return;
+
+ switch (type) {
+ case INI_ITEM_TYPE_BOOL:
+ LOG_INFO("- %-19s = %s", prefix_str, *(gboolean*)item ? "yes" : "no");
+ break;
+ case INI_ITEM_TYPE_INT:
+ LOG_INFO("- %-19s = %d", prefix_str, *(int*)item);
+ break;
+ case INI_ITEM_TYPE_STRING:
+ LOG_INFO("- %-19s = %s", prefix_str, (const char *)item);
+ break;
+ case INI_ITEM_TYPE_STRINGS: {
+ gchar *joined_str = g_strjoinv(" ", item);
+ LOG_INFO("- %-19s = %s", prefix_str, joined_str);
+ g_free(joined_str);
+ break;
+ }
+ default:
+ LOG_ERROR("not supported type[%d]", type);
+ break;
+ }
+}
+
+static void __dump_ini(webrtc_ini_s *ini)
+{
+ RET_IF(ini == NULL, "ini is NULL");
+
+ LOG_INFO("[general]");
+ __dump_item("generate dot", INI_ITEM_TYPE_BOOL, &ini->general.generate_dot);
+ __dump_item("dot path", INI_ITEM_TYPE_STRING, (void *)ini->general.dot_path);
+ __dump_item("gstreamer arguments", INI_ITEM_TYPE_STRINGS, ini->general.gst_args);
+ __dump_item("gstreamer excluded elements", INI_ITEM_TYPE_STRINGS, ini->general.gst_excluded_elements);
+
+ LOG_INFO("[media source]");
+ __dump_item("video format", INI_ITEM_TYPE_STRING, (void *)ini->media_source.v_format);
+ __dump_item("video width", INI_ITEM_TYPE_INT, &ini->media_source.v_width);
+ __dump_item("video height", INI_ITEM_TYPE_INT, &ini->media_source.v_height);
+ __dump_item("video framerate", INI_ITEM_TYPE_INT, &ini->media_source.v_framerate);
+ __dump_item("audio format", INI_ITEM_TYPE_STRING, (void *)ini->media_source.a_format);
+ __dump_item("audio samplerate", INI_ITEM_TYPE_INT, &ini->media_source.a_samplerate);
+ __dump_item("audio channels", INI_ITEM_TYPE_INT, &ini->media_source.a_channels);
+
+ LOG_INFO("[codec]");
+ __dump_item("video codec", INI_ITEM_TYPE_STRING, (void *)ini->codec.video);
+ __dump_item("audio codec", INI_ITEM_TYPE_STRING, (void *)ini->codec.audio);
+}
static const char* __get_delimiter(const char *ini_path)
{
int _load_ini(webrtc_s *webrtc)
{
- const char *dot_path;
+ webrtc_ini_s *ini;
RET_VAL_IF(webrtc == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "webrtc is NULL");
memset(&webrtc->ini, 0, sizeof(webrtc_ini_s));
+ ini = &webrtc->ini;
- webrtc->ini.dict = iniparser_load(WEBRTC_INI_PATH);
- if (!webrtc->ini.dict)
+ ini->dict = iniparser_load(WEBRTC_INI_PATH);
+ if (!ini->dict)
LOG_WARNING("could not open ini[%s], use default values", WEBRTC_INI_PATH);
- webrtc->ini.generate_dot = iniparser_getboolean(webrtc->ini.dict, INI_ITEM_GENERAL_DOT_GENERATE, DEFAULT_GENERATE_DOT);
-
- dot_path = iniparser_getstring(webrtc->ini.dict, INI_ITEM_GENERAL_DOT_PATH, DEFAULT_DOT_PATH);
- if (webrtc->ini.generate_dot) {
- LOG_INFO("dot file will be stored in [%s]", dot_path);
- g_setenv("GST_DEBUG_DUMP_DOT_DIR", dot_path, FALSE);
+ /* general */
+ ini->general.generate_dot = iniparser_getboolean(ini->dict, INI_ITEM_GENERAL_DOT_GENERATE, DEFAULT_GENERATE_DOT);
+ ini->general.dot_path = iniparser_getstring(ini->dict, INI_ITEM_GENERAL_DOT_PATH, DEFAULT_DOT_PATH);
+ if (ini->general.generate_dot) {
+ LOG_INFO("dot file will be stored in [%s]", ini->general.dot_path);
+ g_setenv("GST_DEBUG_DUMP_DOT_DIR", ini->general.dot_path, FALSE);
}
+ __ini_read_list(ini->dict, INI_ITEM_GENERAL_GST_ARGS, &ini->general.gst_args);
+ __ini_read_list(ini->dict, INI_ITEM_GENERAL_GST_EXCLUDED_ELEMENTS, &ini->general.gst_excluded_elements);
+
+ /* media source */
+ ini->media_source.v_format = iniparser_getstring(ini->dict, INI_ITEM_MEDIA_SOURCE_V_FORMAT, DEFAULT_VIDEO_RAW_FORMAT);
+ ini->media_source.v_width = iniparser_getint(ini->dict, INI_ITEM_MEDIA_SOURCE_V_WIDTH, DEFAULT_VIDEO_WIDTH);
+ ini->media_source.v_height = iniparser_getint(ini->dict, INI_ITEM_MEDIA_SOURCE_V_HEIGHT, DEFAULT_VIDEO_HEIGHT);
+ ini->media_source.v_framerate = iniparser_getint(ini->dict, INI_ITEM_MEDIA_SOURCE_V_FRAMERATE, DEFAULT_VIDEO_FRAMERATE);
+ ini->media_source.a_format = iniparser_getstring(ini->dict, INI_ITEM_MEDIA_SOURCE_A_FORMAT, DEFAULT_AUDIO_RAW_FORMAT);
+ ini->media_source.a_samplerate = iniparser_getint(ini->dict, INI_ITEM_MEDIA_SOURCE_A_SAMPLERATE, DEFAULT_AUDIO_SAMPLERATE);
+ ini->media_source.a_channels = iniparser_getint(ini->dict, INI_ITEM_MEDIA_SOURCE_A_CHANNELS, DEFAULT_AUDIO_CHANNELS);
- __ini_read_list(webrtc->ini.dict, INI_ITEM_GENERAL_GST_ARGS, &webrtc->ini.gst_args);
+ /* codec */
+ ini->codec.video = iniparser_getstring(ini->dict, INI_ITEM_CODEC_VIDEO, DEFAULT_VIDEO_CODEC);
+ ini->codec.audio = iniparser_getstring(ini->dict, INI_ITEM_CODEC_AUDIO, DEFAULT_AUDIO_CODEC);
- __ini_read_list(webrtc->ini.dict, INI_ITEM_GENERAL_GST_EXCLUDED_ELEMENTS, &webrtc->ini.gst_excluded_elements);
+ __dump_ini(ini);
return WEBRTC_ERROR_NONE;
}
RET_IF(webrtc == NULL, "webrtc is NULL");
RET_IF(webrtc->ini.dict == NULL, "ini.dict is NULL");
- g_strfreev(webrtc->ini.gst_args);
- webrtc->ini.gst_args = NULL;
+ g_strfreev(webrtc->ini.general.gst_args);
+ webrtc->ini.general.gst_args = NULL;
- g_strfreev(webrtc->ini.gst_excluded_elements);
- webrtc->ini.gst_excluded_elements = NULL;
+ g_strfreev(webrtc->ini.general.gst_excluded_elements);
+ webrtc->ini.general.gst_excluded_elements = NULL;
iniparser_freedict(webrtc->ini.dict);
LOG_DEBUG("ini instance[%p] is freed", webrtc->ini.dict);
#define DEFAULT_ELEMENT_CAPSFILTER "capsfilter"
#define DEFAULT_ELEMENT_QUEUE "queue"
-#define DEFAULT_VIDEO_ENCODED_MEDIA_TYPE "video/x-vp8"
-#define DEFAULT_VIDEO_RAW_MEDIA_TYPE "video/x-raw"
-#define DEFAULT_VIDEO_RAW_FORMAT "I420"
-#define DEFAULT_VIDEO_WIDTH 352
-#define DEFAULT_VIDEO_HEIGHT 288
-
-#define DEFAULT_AUDIO_ENCODED_MEDIA_TYPE "audio/x-opus"
-#define DEFAULT_AUDIO_RAW_MEDIA_TYPE "audio/x-raw"
-#define DEFAULT_AUDIO_RAW_FORMAT "S16LE"
-#define DEFAULT_AUDIO_CHANNELS 1
-#define DEFAULT_AUDIO_SAMPLERATE 8000
+#define MEDIA_TYPE_AUDIO_RAW "audio/x-raw"
+#define MEDIA_TYPE_AUDIO_OPUS "audio/x-opus"
+#define MEDIA_TYPE_AUDIO_VORBIS "audio/x-vorbis"
+#define MEDIA_TYPE_VIDEO_RAW "video/x-raw"
+#define MEDIA_TYPE_VIDEO_VP8 "video/x-vp8"
+#define MEDIA_TYPE_VIDEO_VP9 "video/x-vp9"
+#define MEDIA_TYPE_VIDEO_THEORA "video/x-theora"
+#define MEDIA_TYPE_VIDEO_H263 "video/x-h263"
+#define MEDIA_TYPE_VIDEO_H264 "video/x-h264"
+#define MEDIA_TYPE_VIDEO_H265 "video/x-h265"
typedef enum {
CODEC_TYPE_OPUS,
[CODEC_TYPE_H265] = { "H265", 90000 },
};
-static GstCaps *__make_default_raw_caps(webrtc_media_source_type_e type)
+static const char * __get_audio_media_type(const char *codec_name)
+{
+ RET_VAL_IF(codec_name == NULL, NULL, "codec_name is NULL");
+
+ if (!strcmp(codec_name, "opus") || !strcmp(codec_name, "OPUS"))
+ return MEDIA_TYPE_AUDIO_OPUS;
+ else if (!strcmp(codec_name, "vorbis") || !strcmp(codec_name, "VORBIS"))
+ return MEDIA_TYPE_AUDIO_VORBIS;
+
+ LOG_ERROR("not supported audio codec_name[%s]", codec_name);
+
+ return NULL;
+}
+
+static const char * __get_video_media_type(const char *codec_name)
+{
+ RET_VAL_IF(codec_name == NULL, NULL, "codec_name is NULL");
+
+ if (!strcmp(codec_name, "vp8") || !strcmp(codec_name, "VP8"))
+ return MEDIA_TYPE_VIDEO_VP8;
+ else if (!strcmp(codec_name, "vp9") || !strcmp(codec_name, "VP9"))
+ return MEDIA_TYPE_VIDEO_VP9;
+ else if (!strcmp(codec_name, "theora") || !strcmp(codec_name, "THEORA"))
+ return MEDIA_TYPE_VIDEO_THEORA;
+ else if (!strcmp(codec_name, "h263") || !strcmp(codec_name, "H263"))
+ return MEDIA_TYPE_VIDEO_H263;
+ else if (!strcmp(codec_name, "h264") || !strcmp(codec_name, "H264"))
+ return MEDIA_TYPE_VIDEO_H264;
+ else if (!strcmp(codec_name, "h265") || !strcmp(codec_name, "H265"))
+ return MEDIA_TYPE_VIDEO_H265;
+
+ LOG_ERROR("not supported video codec_name[%s]", codec_name);
+
+ return NULL;
+}
+
+static codec_type_e __get_audio_codec_type(const gchar *media_type)
+{
+ if (!g_strcmp0(media_type, MEDIA_TYPE_AUDIO_OPUS))
+ return CODEC_TYPE_OPUS;
+ else if (!g_strcmp0(media_type, MEDIA_TYPE_AUDIO_VORBIS))
+ return CODEC_TYPE_VORBIS;
+
+ return CODEC_TYPE_NOT_SUPPORTED;
+}
+
+static codec_type_e __get_video_codec_type(const gchar *media_type)
+{
+ if (!g_strcmp0(media_type, MEDIA_TYPE_VIDEO_VP8))
+ return CODEC_TYPE_VP8;
+ else if (!g_strcmp0(media_type, MEDIA_TYPE_VIDEO_VP9))
+ return CODEC_TYPE_VP9;
+ else if (!g_strcmp0(media_type, MEDIA_TYPE_VIDEO_THEORA))
+ return CODEC_TYPE_THEORA;
+ else if (!g_strcmp0(media_type, MEDIA_TYPE_VIDEO_H263))
+ return CODEC_TYPE_H263;
+ else if (!g_strcmp0(media_type, MEDIA_TYPE_VIDEO_H264))
+ return CODEC_TYPE_H264;
+ else if (!g_strcmp0(media_type, MEDIA_TYPE_VIDEO_H265))
+ return CODEC_TYPE_H265;
+
+ return CODEC_TYPE_NOT_SUPPORTED;
+}
+
+static GstCaps *__make_default_raw_caps(webrtc_media_source_type_e type, webrtc_ini_s *ini)
{
GstCaps *caps = NULL;
+ RET_VAL_IF(ini == NULL, NULL, "ini is NULL");
+
switch (type) {
case WEBRTC_MEDIA_SOURCE_TYPE_CAMERA:
case WEBRTC_MEDIA_SOURCE_TYPE_VIDEOTEST:
- /* FIXME: get default value from ini */
- caps = gst_caps_new_simple(DEFAULT_VIDEO_RAW_MEDIA_TYPE,
- "format", G_TYPE_STRING, DEFAULT_VIDEO_RAW_FORMAT,
- "width", G_TYPE_INT, DEFAULT_VIDEO_WIDTH,
- "height", G_TYPE_INT, DEFAULT_VIDEO_HEIGHT,
+ caps = gst_caps_new_simple(MEDIA_TYPE_VIDEO_RAW,
+ "format", G_TYPE_STRING, ini->media_source.v_format,
+ "framerate", GST_TYPE_FRACTION, ini->media_source.v_framerate, 1,
+ "width", G_TYPE_INT, ini->media_source.v_width,
+ "height", G_TYPE_INT, ini->media_source.v_height,
NULL);
break;
case WEBRTC_MEDIA_SOURCE_TYPE_MIC:
case WEBRTC_MEDIA_SOURCE_TYPE_AUDIOTEST:
- /* FIXME: get default value from ini */
- caps = gst_caps_new_simple(DEFAULT_AUDIO_RAW_MEDIA_TYPE,
- "format", G_TYPE_STRING, DEFAULT_AUDIO_RAW_FORMAT,
- "channels", G_TYPE_INT, DEFAULT_AUDIO_CHANNELS,
- "rate", G_TYPE_INT, DEFAULT_AUDIO_SAMPLERATE,
+ caps = gst_caps_new_simple(MEDIA_TYPE_AUDIO_RAW,
+ "format", G_TYPE_STRING, ini->media_source.a_format,
+ "channels", G_TYPE_INT, ini->media_source.a_channels,
+ "rate", G_TYPE_INT, ini->media_source.a_samplerate,
NULL);
break;
}
/* Use g_free() to free the media_type parameter. */
-static GstCaps *__make_default_encoded_caps(webrtc_media_source_type_e type, gchar **media_type)
+static GstCaps *__make_default_encoded_caps(webrtc_media_source_type_e type, webrtc_ini_s *ini, gchar **media_type)
{
GstCaps *caps;
const char *_media_type;
+ RET_VAL_IF(ini == NULL, NULL, "ini is NULL");
+
switch (type) {
case WEBRTC_MEDIA_SOURCE_TYPE_CAMERA:
case WEBRTC_MEDIA_SOURCE_TYPE_VIDEOTEST:
- /* FIXME: get default value from ini */
- _media_type = DEFAULT_VIDEO_ENCODED_MEDIA_TYPE;
+ _media_type = __get_video_media_type(ini->codec.video);
caps = gst_caps_new_simple(_media_type,
- "width", G_TYPE_INT, DEFAULT_VIDEO_WIDTH,
- "height", G_TYPE_INT, DEFAULT_VIDEO_HEIGHT,
+ "framerate", GST_TYPE_FRACTION, ini->media_source.v_framerate, 1,
+ "width", G_TYPE_INT, ini->media_source.v_width,
+ "height", G_TYPE_INT, ini->media_source.v_height,
NULL);
break;
case WEBRTC_MEDIA_SOURCE_TYPE_MIC:
case WEBRTC_MEDIA_SOURCE_TYPE_AUDIOTEST:
- /* FIXME: get default value from ini */
- _media_type = DEFAULT_AUDIO_ENCODED_MEDIA_TYPE;
- caps = gst_caps_new_simple(DEFAULT_AUDIO_ENCODED_MEDIA_TYPE,
- "channels", G_TYPE_INT, DEFAULT_AUDIO_CHANNELS,
- "rate", G_TYPE_INT, DEFAULT_AUDIO_SAMPLERATE,
+ _media_type = __get_audio_media_type(ini->codec.audio);
+ caps = gst_caps_new_simple(_media_type,
+ "channels", G_TYPE_INT, ini->media_source.a_channels,
+ "rate", G_TYPE_INT, ini->media_source.a_samplerate,
NULL);
break;
return caps;
}
-static codec_type_e __get_codec_type(const gchar *media_type)
-{
- if (!g_strcmp0(media_type, "audio/x-opus"))
- return CODEC_TYPE_OPUS;
- else if (!g_strcmp0(media_type, "audio/x-vorbis"))
- return CODEC_TYPE_VORBIS;
- else if (!g_strcmp0(media_type, "video/x-vp8"))
- return CODEC_TYPE_VP8;
- else if (!g_strcmp0(media_type, "video/x-vp9"))
- return CODEC_TYPE_VP9;
- else if (!g_strcmp0(media_type, "video/x-theora"))
- return CODEC_TYPE_THEORA;
- else if (!g_strcmp0(media_type, "video/x-h263"))
- return CODEC_TYPE_H263;
- else if (!g_strcmp0(media_type, "video/x-h264"))
- return CODEC_TYPE_H264;
- else if (!g_strcmp0(media_type, "video/x-h265"))
- return CODEC_TYPE_H265;
- else
- return CODEC_TYPE_NOT_SUPPORTED;
-}
-
static GstCaps *__make_rtp_caps(const gchar *media_type, unsigned int id)
{
gchar *caps_str;
GstCaps *caps;
- codec_type_e codec_type = __get_codec_type(media_type);
+ gboolean is_video;
+ codec_type_e codec_type;
+
+ RET_VAL_IF(media_type == NULL, NULL, "media_type is NULL");
+
+ is_video = g_strrstr(media_type, "video") ? TRUE : FALSE;
+ codec_type = is_video ? __get_video_codec_type(media_type) : __get_audio_codec_type(media_type);
RET_VAL_IF(codec_type == CODEC_TYPE_NOT_SUPPORTED, NULL, "media_type[%s] is not supported", media_type);
caps = gst_caps_new_simple("application/x-rtp",
- "media", G_TYPE_STRING, g_strrstr(media_type, "video") ? "video" : "audio",
+ "media", G_TYPE_STRING, is_video ? "video" : "audio",
"clock-rate", G_TYPE_INT, payload_types[codec_type].clock_rate, /* FIXME: support various clock-rate */
"encoding-name", G_TYPE_STRING, payload_types[codec_type].encoding_name,
"payload", G_TYPE_INT, id + 95, NULL);
caps_str = gst_caps_to_string(caps);
- LOG_DEBUG("RTP caps is created [%s]", caps_str);
+ LOG_INFO("RTP caps is created [%s]", caps_str);
g_free(caps_str);
return caps;
}
-static int __create_rest_of_elements(webrtc_gst_slot_s *source, webrtc_media_source_type_e type, GstElement **capsfilter, GstElement **encoder, GstElement **payloader, GstElement **queue, GstElement **capsfilter2)
+static int __create_rest_of_elements(webrtc_s *webrtc, webrtc_gst_slot_s *source, webrtc_media_source_type_e type,
+ GstElement **capsfilter, GstElement **encoder, GstElement **payloader, GstElement **queue, GstElement **capsfilter2)
{
GstCaps *sink_caps;
element_info_s elem_info;
const gchar *encoder_klass_name;
gchar *media_type;
+ RET_VAL_IF(webrtc == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "webrtc is NULL");
RET_VAL_IF(source == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "source is NULL");
RET_VAL_IF(capsfilter == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "capsfilter is NULL");
RET_VAL_IF(encoder == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "encoder is NULL");
LOG_ERROR("failed to create capsfilter");
return WEBRTC_ERROR_INVALID_OPERATION;
}
- if ((sink_caps = __make_default_raw_caps(type))) {
+ if ((sink_caps = __make_default_raw_caps(type, &webrtc->ini))) {
g_object_set(G_OBJECT(*capsfilter), "caps", sink_caps, NULL);
gst_caps_unref(sink_caps);
}
encoder_klass_name = GST_KLASS_NAME_ENCODER_AUDIO;
CREATE_ELEMENT_FROM_REGISTRY(elem_info, encoder_klass_name,
- __make_default_raw_caps(type),
- __make_default_encoded_caps(type, NULL),
+ __make_default_raw_caps(type, &webrtc->ini),
+ __make_default_encoded_caps(type, &webrtc->ini, NULL),
*encoder);
CREATE_ELEMENT_FROM_REGISTRY(elem_info, GST_KLASS_NAME_PAYLOADER_RTP,
- __make_default_encoded_caps(type, &media_type),
+ __make_default_encoded_caps(type, &webrtc->ini, &media_type),
NULL,
*payloader);
return WEBRTC_ERROR_NONE;
}
-static int __build_camerasrc(webrtc_gst_slot_s *source, GstPad *ghost_src_pad)
+static int __build_camerasrc(webrtc_s *webrtc, webrtc_gst_slot_s *source, GstPad *ghost_src_pad)
{
int ret = WEBRTC_ERROR_NONE;
GstElement *camerasrc;
GstElement *queue;
GstElement *capsfilter2;
+ RET_VAL_IF(webrtc == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "webrtc is NULL");
RET_VAL_IF(source == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "source is NULL");
RET_VAL_IF(ghost_src_pad == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "ghost_src_pad is NULL");
RET_VAL_IF(source->bin == NULL, WEBRTC_ERROR_INVALID_OPERATION, "bin is NULL");
}
/* FIXME: set camera default setting from ini */
- if ((ret = __create_rest_of_elements(source, WEBRTC_MEDIA_SOURCE_TYPE_CAMERA, &capsfilter, &videoenc, &videopay, &queue, &capsfilter2)) != WEBRTC_ERROR_NONE)
+ if ((ret = __create_rest_of_elements(webrtc, source, WEBRTC_MEDIA_SOURCE_TYPE_CAMERA, &capsfilter, &videoenc, &videopay, &queue, &capsfilter2)) != WEBRTC_ERROR_NONE)
return ret;
gst_bin_add_many(GST_BIN(source->bin), camerasrc, capsfilter, videoenc, videopay, queue, capsfilter2, NULL);
return _set_ghost_pad_target(ghost_src_pad, capsfilter2, TRUE);
}
-static int __build_audiosrc(webrtc_gst_slot_s *source, GstPad *ghost_src_pad)
+static int __build_audiosrc(webrtc_s *webrtc, webrtc_gst_slot_s *source, GstPad *ghost_src_pad)
{
int ret = WEBRTC_ERROR_NONE;
GstElement *audiosrc;
GstElement *queue;
GstElement *capsfilter2;
+ RET_VAL_IF(webrtc == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "webrtc is NULL");
RET_VAL_IF(source == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "source is NULL");
RET_VAL_IF(ghost_src_pad == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "ghost_src_pad is NULL");
RET_VAL_IF(source->bin == NULL, WEBRTC_ERROR_INVALID_OPERATION, "bin is NULL");
return WEBRTC_ERROR_INVALID_OPERATION;
}
- if ((ret = __create_rest_of_elements(source, WEBRTC_MEDIA_SOURCE_TYPE_MIC, &capsfilter, &audioenc, &audiopay, &queue, &capsfilter2)) != WEBRTC_ERROR_NONE)
+ if ((ret = __create_rest_of_elements(webrtc, source, WEBRTC_MEDIA_SOURCE_TYPE_MIC, &capsfilter, &audioenc, &audiopay, &queue, &capsfilter2)) != WEBRTC_ERROR_NONE)
return ret;
gst_bin_add_many(GST_BIN(source->bin), audiosrc, capsfilter, audioenc, audiopay, queue, capsfilter2, NULL);
return _set_ghost_pad_target(ghost_src_pad, capsfilter2, TRUE);
}
-static int __build_videotestsrc(webrtc_gst_slot_s *source, GstPad *ghost_src_pad)
+static int __build_videotestsrc(webrtc_s *webrtc, webrtc_gst_slot_s *source, GstPad *ghost_src_pad)
{
int ret = WEBRTC_ERROR_NONE;
GstElement *videotestsrc;
GstElement *queue;
GstElement *capsfilter2;
+ RET_VAL_IF(webrtc == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "webrtc is NULL");
RET_VAL_IF(source == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "source is NULL");
RET_VAL_IF(ghost_src_pad == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "ghost_src_pad is NULL");
RET_VAL_IF(source->bin == NULL, WEBRTC_ERROR_INVALID_OPERATION, "bin is NULL");
}
g_object_set(G_OBJECT(videotestsrc), "is-live", TRUE, NULL);
- if ((ret = __create_rest_of_elements(source, WEBRTC_MEDIA_SOURCE_TYPE_VIDEOTEST, &capsfilter, &videoenc, &videopay, &queue, &capsfilter2)) != WEBRTC_ERROR_NONE)
+ if ((ret = __create_rest_of_elements(webrtc, source, WEBRTC_MEDIA_SOURCE_TYPE_VIDEOTEST, &capsfilter, &videoenc, &videopay, &queue, &capsfilter2)) != WEBRTC_ERROR_NONE)
return ret;
gst_bin_add_many(GST_BIN(source->bin), videotestsrc, capsfilter, videoenc, videopay, queue, capsfilter2, NULL);
return _set_ghost_pad_target(ghost_src_pad, capsfilter2, TRUE);
}
-static int __build_audiotestsrc(webrtc_gst_slot_s *source, GstPad *ghost_src_pad)
+static int __build_audiotestsrc(webrtc_s *webrtc, webrtc_gst_slot_s *source, GstPad *ghost_src_pad)
{
int ret = WEBRTC_ERROR_NONE;
GstElement *audiotestsrc;
GstElement *queue;
GstElement *capsfilter2;
+ RET_VAL_IF(webrtc == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "webrtc is NULL");
RET_VAL_IF(source == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "source is NULL");
RET_VAL_IF(ghost_src_pad == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "ghost_src_pad is NULL");
RET_VAL_IF(source->bin == NULL, WEBRTC_ERROR_INVALID_OPERATION, "bin is NULL");
}
g_object_set(G_OBJECT(audiotestsrc), "is-live", TRUE, NULL);
- if ((ret = __create_rest_of_elements(source, WEBRTC_MEDIA_SOURCE_TYPE_AUDIOTEST, &capsfilter, &audioenc, &audiopay, &queue, &capsfilter2)) != WEBRTC_ERROR_NONE)
+ if ((ret = __create_rest_of_elements(webrtc, source, WEBRTC_MEDIA_SOURCE_TYPE_AUDIOTEST, &capsfilter, &audioenc, &audiopay, &queue, &capsfilter2)) != WEBRTC_ERROR_NONE)
return ret;
gst_bin_add_many(GST_BIN(source->bin), audiotestsrc, capsfilter, audioenc, audiopay, queue, capsfilter2, NULL);
return _set_ghost_pad_target(ghost_src_pad, capsfilter2, TRUE);
}
-static int __build_source_bin(webrtc_gst_slot_s *source, webrtc_media_source_type_e type)
+static int __build_source_bin(webrtc_s *webrtc, webrtc_gst_slot_s *source, webrtc_media_source_type_e type)
{
int ret = WEBRTC_ERROR_NONE;
GstPad *src_pad;
+ RET_VAL_IF(webrtc == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "webrtc is NULL");
RET_VAL_IF(source == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "source is NULL");
RET_VAL_IF(source->bin == NULL, WEBRTC_ERROR_INVALID_OPERATION, "bin is NULL");
switch (type) {
case WEBRTC_MEDIA_SOURCE_TYPE_CAMERA:
- return __build_camerasrc(source, src_pad);
+ return __build_camerasrc(webrtc, source, src_pad);
case WEBRTC_MEDIA_SOURCE_TYPE_MIC:
- return __build_audiosrc(source, src_pad);
+ return __build_audiosrc(webrtc, source, src_pad);
case WEBRTC_MEDIA_SOURCE_TYPE_VIDEOTEST:
- return __build_videotestsrc(source, src_pad);
+ return __build_videotestsrc(webrtc, source, src_pad);
case WEBRTC_MEDIA_SOURCE_TYPE_AUDIOTEST:
- return __build_audiotestsrc(source, src_pad);
+ return __build_audiotestsrc(webrtc, source, src_pad);
default:
LOG_ERROR_IF_REACHED("type(%d)", type);
MALLOC_AND_INIT_SLOT(source, id, bin_name, webrtc->gst.webrtcbin);
- ret = __build_source_bin(source, type);
+ ret = __build_source_bin(webrtc, source, type);
if (ret != WEBRTC_ERROR_NONE) {
LOG_ERROR("failed to __build_source_bin()");
goto error;