webrtc_source: Add support for G.711 one of mandatory audio codecs 60/263160/3
authorSangchul Lee <sc11.lee@samsung.com>
Fri, 27 Aug 2021 03:51:09 +0000 (12:51 +0900)
committerSangchul Lee <sc11.lee@samsung.com>
Fri, 27 Aug 2021 04:53:25 +0000 (13:53 +0900)
PCMU and PCMA which support 64kbps with 8kHz sample rates are added.
Please refer to https://datatracker.ietf.org/doc/html/rfc7874 for
more details.

[Version] 0.2.86
[Issue Type] New feature

Change-Id: I56b2972817a652761cc8f0249d4ecf29389ec0df
Signed-off-by: Sangchul Lee <sc11.lee@samsung.com>
include/webrtc.h
include/webrtc_private.h
packaging/capi-media-webrtc.spec
src/webrtc_source.c

index 23f5440e1e91f3e1ce103153bd85441b9713fdb1..a0115f42e63c69c0ad291b84d651e4da550b9508 100644 (file)
@@ -980,6 +980,8 @@ int webrtc_media_packet_source_unset_buffer_state_changed_cb(webrtc_h webrtc, un
  *          #MEDIA_FORMAT_VORBIS\n
  *          #MEDIA_FORMAT_OPUS\n
  *          #MEDIA_FORMAT_PCM_S16LE\n
+ *          #MEDIA_FORMAT_PCMU\n
+ *          #MEDIA_FORMAT_PCMA\n
  *          #MEDIA_FORMAT_H264_SP\n
  *          #MEDIA_FORMAT_H264_MP\n
  *          #MEDIA_FORMAT_H264_HP\n
index 4f6710816c1ab118c55bc8024859b686feefe5d0..921f6058c3818808b20e8255b44ceb5b58a1bfc9 100644 (file)
@@ -208,6 +208,8 @@ do { \
 #define GST_KLASS_NAME_DEPAYLOADER_RTP "Codec/Depayloader/Network/RTP"
 
 #define MEDIA_TYPE_AUDIO_RAW            "audio/x-raw"
+#define MEDIA_TYPE_AUDIO_MULAW          "audio/x-mulaw"
+#define MEDIA_TYPE_AUDIO_ALAW           "audio/x-alaw"
 #define MEDIA_TYPE_AUDIO_OPUS           "audio/x-opus"
 #define MEDIA_TYPE_AUDIO_VORBIS         "audio/x-vorbis"
 #define MEDIA_TYPE_VIDEO_RAW            "video/x-raw"
index 8adbccf4c9ccabde3b66709f8e501ab16348de56..9a64aa85f1a31fde3a6ce02c686184ff8e25f5f8 100644 (file)
@@ -1,6 +1,6 @@
 Name:       capi-media-webrtc
 Summary:    A WebRTC library in Tizen Native API
-Version:    0.2.85
+Version:    0.2.86
 Release:    0
 Group:      Multimedia/API
 License:    Apache-2.0
index 4ec95c65756ee9fd6dc8e293771c646b5bccb31d..1302bea51c8c755861e99030283a4f0e7980a906 100644 (file)
@@ -96,9 +96,13 @@ 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, "pcmu") || !strcmp(codec_name, "PCMU"))
+               return MEDIA_TYPE_AUDIO_MULAW;
+       if (!strcmp(codec_name, "pcma") || !strcmp(codec_name, "PCMA"))
+               return MEDIA_TYPE_AUDIO_ALAW;
        if (!strcmp(codec_name, "opus") || !strcmp(codec_name, "OPUS"))
                return MEDIA_TYPE_AUDIO_OPUS;
-       else if (!strcmp(codec_name, "vorbis") || !strcmp(codec_name, "VORBIS"))
+       if (!strcmp(codec_name, "vorbis") || !strcmp(codec_name, "VORBIS"))
                return MEDIA_TYPE_AUDIO_VORBIS;
 
        LOG_ERROR("not supported audio codec_name[%s]", codec_name);
@@ -112,15 +116,15 @@ static const char * __get_video_media_type(const char *codec_name)
 
        if (!strcmp(codec_name, "vp8") || !strcmp(codec_name, "VP8"))
                return MEDIA_TYPE_VIDEO_VP8;
-       else if (!strcmp(codec_name, "vp9") || !strcmp(codec_name, "VP9"))
+       if (!strcmp(codec_name, "vp9") || !strcmp(codec_name, "VP9"))
                return MEDIA_TYPE_VIDEO_VP9;
-       else if (!strcmp(codec_name, "theora") || !strcmp(codec_name, "THEORA"))
+       if (!strcmp(codec_name, "theora") || !strcmp(codec_name, "THEORA"))
                return MEDIA_TYPE_VIDEO_THEORA;
-       else if (!strcmp(codec_name, "h264") || !strcmp(codec_name, "H264"))
+       if (!strcmp(codec_name, "h264") || !strcmp(codec_name, "H264"))
                return MEDIA_TYPE_VIDEO_H264;
-       else if (!strcmp(codec_name, "h265") || !strcmp(codec_name, "H265"))
+       if (!strcmp(codec_name, "h265") || !strcmp(codec_name, "H265"))
                return MEDIA_TYPE_VIDEO_H265;
-       else if (!strcmp(codec_name, "jpeg") || !strcmp(codec_name, "JPEG") || !strcmp(codec_name, "mjpeg") || !strcmp(codec_name, "MJPEG"))
+       if (!strcmp(codec_name, "jpeg") || !strcmp(codec_name, "JPEG") || !strcmp(codec_name, "mjpeg") || !strcmp(codec_name, "MJPEG"))
                return MEDIA_TYPE_VIDEO_JPEG;
 
        LOG_ERROR("not supported video codec_name[%s]", codec_name);
@@ -135,6 +139,10 @@ static const char *__get_audio_format_name(media_format_mimetype_e mime_type)
        case MEDIA_FORMAT_PCM_S16LE:
                return "S16LE";
        /* ENCODED formats */
+       case MEDIA_FORMAT_PCMU:
+               return "PCMU";
+       case MEDIA_FORMAT_PCMA:
+               return "PCMA";
        case MEDIA_FORMAT_OPUS:
                return "OPUS";
        case MEDIA_FORMAT_VORBIS:
@@ -210,6 +218,8 @@ static bool __is_supported_mime_type(media_format_mimetype_e mime_type)
                LOG_INFO("[VIDEO][RAW/%s] mime_type[0x%x]", __get_video_format_name(mime_type, false), mime_type);
                return true;
        /* AUDIO/ENCODED formats */
+       case MEDIA_FORMAT_PCMU:
+       case MEDIA_FORMAT_PCMA:
        case MEDIA_FORMAT_OPUS:
        case MEDIA_FORMAT_VORBIS:
                LOG_INFO("[AUDIO][ENCODED/%s] mime_type[0x%x]", __get_audio_format_name(mime_type), mime_type);
@@ -405,6 +415,13 @@ static GstCaps *__get_caps_from_encoded_audio_media_type(const char *media_type,
 {
        RET_VAL_IF(media_type == NULL, NULL, "media_type is NULL");
 
+       if (!strcmp(media_type, MEDIA_TYPE_AUDIO_MULAW) ||
+               !strcmp(media_type, MEDIA_TYPE_AUDIO_ALAW))
+               return gst_caps_new_simple(media_type,
+                       "rate", G_TYPE_INT, samplerate,
+                       "channels", G_TYPE_INT, channels,
+                       NULL);
+
        if (!strcmp(media_type, MEDIA_TYPE_AUDIO_OPUS) ||
                !strcmp(media_type, MEDIA_TYPE_AUDIO_VORBIS))
                return gst_caps_new_simple(media_type, NULL, NULL);
@@ -2683,7 +2700,8 @@ int _set_media_format(webrtc_s *webrtc, unsigned int source_id, media_format_h f
        media_format_ref(format);
        source->media_format = format;
 
-       if (mime_type & MEDIA_FORMAT_RAW)
+       if ((mime_type & MEDIA_FORMAT_RAW) &&
+               !(mime_type == MEDIA_FORMAT_PCMU || mime_type == MEDIA_FORMAT_PCMA)) /* FIXME: media_format.h defined PCMU/PCMA as a raw format, it's a bug. */
                ret = __complete_mediapacketsrc_from_raw_format(webrtc, source);
        else
                ret = __complete_mediapacketsrc_from_encoded_format(webrtc, source);