#include "MediaTransporter.h"
#include "MediaTransporterGst.h"
+#include "MediaTransporterParam.h"
#include "MediaSourceBinBase.h"
namespace tizen_media_transporter {
MediaSourceBinInfo generate() override;
private:
- void parseSourceParam(bundle* params);
GstElement* createMicSource();
void setEncoderParam(gst::GstElements& elements);
void setSourceParam(gst::GstElements& elements);
void replaceCapsWithAudioInfo(GstElement* element);
void replaceEncCapsWithAudioInfo(GstElement* element);
- struct audioInfo {
- int channel { -1 };
- int rate { -1 };
- std::string format;
- };
- audioInfo _audioInfo;
-
- struct encodingInfo {
- int bitrate = 0;
- };
- encodingInfo _encInfo;
-
+ param::audioInfo _audioInfo;
+ param::encodingInfo _encInfo;
};
} // namespace
#include "MediaTransporter.h"
#include "MediaTransporterGst.h"
+#include "MediaTransporterParam.h"
#include "MediaSourceBinBase.h"
namespace tizen_media_transporter {
MediaSourceBinInfo generate() override;
private:
- void parseSourceParam(bundle* params);
GstElement* createCameraSource();
void setEncoderParam(gst::GstElements& elements);
void setSourceParam(gst::GstElements& elements);
void replaceCapsWithVideoInfo(GstElement* element);
void replaceEncCapsWithVideoInfo(GstElement* element);
- struct videoInfo {
- int width { -1 };
- int height { -1 };
- int frameRate { -1 };
- };
- videoInfo _videoInfo;
-
- struct encodingInfo {
- int bitrate { 0 };
- };
- encodingInfo _encInfo;
-
+ param::videoInfo _videoInfo;
+ param::encodingInfo _encInfo;
};
} // namespace
#include <sound_manager.h>
#include "MediaTransporter.h"
-#include "MediaSourceBinBase.h"
#include "MediaTransporterGst.h"
+#include "MediaTransporterParam.h"
+#include "MediaSourceBinBase.h"
namespace tizen_media_transporter {
void setSoundStreamInfo(sound_stream_info_h streamInfo);
private:
- void parseSourceParam(bundle* params);
GstElement* createMicSource();
void setEncoderParam(gst::GstElements& elements);
void setSourceParam(gst::GstElements& elements);
void replaceCapsWithAudioInfo(GstElement* element);
void replaceEncCapsWithAudioInfo(GstElement* element);
- struct audioInfo {
- int channel { -1 };
- int rate { -1 };
- std::string format;
- };
- audioInfo _audioInfo;
-
- struct encodingInfo {
- int bitrate { 0 };
- };
- encodingInfo _encInfo;
+ param::audioInfo _audioInfo;
+ param::encodingInfo _encInfo;
std::string _streamInfo;
};
#include "MediaTransporter.h"
#include "MediaTransporterGst.h"
+#include "MediaTransporterParam.h"
#include "MediaSourceBinBase.h"
namespace tizen_media_transporter {
MediaSourceBinInfo generate() override;
private:
- void parseSourceParam(bundle* params);
GstElement* createVideoTestSource();
void setEncoderParam(gst::GstElements& elements);
void setSourceParam(gst::GstElements& elements);
void replaceCapsWithVideoInfo(GstElement* element);
void replaceEncCapsWithVideoInfo(GstElement* element);
- struct videoInfo {
- int width { -1 };
- int height { -1 };
- int frameRate { -1 };
- };
- videoInfo _videoInfo;
-
- struct encodingInfo {
- int bitrate { 0 };
- };
- encodingInfo _encInfo;
-
+ param::videoInfo _videoInfo;
+ param::encodingInfo _encInfo;
};
} // namespace
--- /dev/null
+/**
+ * Copyright (c) 2022 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __TIZEN_MEDIA_TRANSPORTER_PARAM_H__
+#define __TIZEN_MEDIA_TRANSPORTER_PARAM_H__
+
+#ifdef __cplusplus
+
+#include <glib.h>
+#include <bundle.h>
+
+namespace tizen_media_transporter {
+namespace param {
+
+struct videoInfo {
+ int width { -1 };
+ int height { -1 };
+ int frameRate { -1 };
+};
+
+struct audioInfo {
+ int channel { -1 };
+ int rate { -1 };
+ std::string format;
+};
+
+struct encodingInfo {
+ int bitrate = 0;
+};
+
+void parseSourceParam(bundle* params, videoInfo* vInfo, encodingInfo* eInfo);
+void parseSourceParam(bundle* params, audioInfo* aInfo, encodingInfo * eInfo);
+}; // param
+
+} // tizen_media_transporter
+
+#endif // __cplusplus
+#endif // __TIZEN_MEDIA_TRANSPORTER_PARAM_H__
/**
* @brief Definition for password parameter of SRT.
- * @details The password for the encrypted transmission of SRT.
+ * @details The password for the encrypted transmission of SRT.\n
+ * The number of characters must be 10 to 79.
* @since_tizen 7.0
* @remarks This is write only parameter.
* @see mtpr_set_connection_params()
Name: capi-media-transporter
Summary: A Media Transporter library in Tizen Native API
-Version: 0.0.5
+Version: 0.0.6
Release: 0
Group: Multimedia/API
License: Apache-2.0
#include "MediaTransporterLog.h"
#include "MediaTransporterException.h"
#include "MediaTransporterParseIni.h"
+#include "MediaTransporterParam.h"
#include <algorithm>
MediaSourceBinAudioTest::MediaSourceBinAudioTest(bundle* params)
{
- parseSourceParam(params);
-}
-
-void MediaSourceBinAudioTest::parseSourceParam(bundle* params)
-{
- int written_count = 0;
- char* string_val = NULL;
-
- RET_IF(!params, "input param is NULL");
-
- /* Will be move to mic/audiotest bin */
- if (bundle_get_str(params, MTPR_SOURCE_PARAM_AUDIO_CHANNEL, &string_val) != BUNDLE_ERROR_KEY_NOT_AVAILABLE) {
- _audioInfo.channel = static_cast<int>(strtoul(string_val, NULL, 10));
- LOG_DEBUG("Source param audio channel %u", _audioInfo.channel);
- written_count++;
- }
-
- if (bundle_get_str(params, MTPR_SOURCE_PARAM_AUDIO_RATE, &string_val) != BUNDLE_ERROR_KEY_NOT_AVAILABLE) {
- _audioInfo.rate = static_cast<int>(strtoul(string_val, NULL, 10));
- LOG_DEBUG("Source param audio rate %u", _audioInfo.rate);
- written_count++;
- }
-
- if (bundle_get_str(params, MTPR_SOURCE_PARAM_AUDIO_FORMAT, &string_val) != BUNDLE_ERROR_KEY_NOT_AVAILABLE) {
- _audioInfo.format = string_val;
- LOG_DEBUG("Source param audio format %s", _audioInfo.format.c_str());
- written_count++;
- }
-
- if (bundle_get_str(params, MTPR_ENCODING_PARAM_BITRATE, &string_val) != BUNDLE_ERROR_KEY_NOT_AVAILABLE) {
- _encInfo.bitrate = (guint)strtoul(string_val, NULL, 10);
- LOG_DEBUG("Encoder target bitrate %u", _encInfo.bitrate);
- written_count++;
- }
-
- if (written_count == 0)
- throw MediaTransporterException(MTPR_ERROR_INVALID_OPERATION, "Failed to parse Source Param");
+ param::parseSourceParam(params, &_audioInfo, &_encInfo);
}
GstElement* MediaSourceBinAudioTest::createMicSource()
#include "MediaTransporterException.h"
#include "MediaTransporterParseIni.h"
#include "MediaTransporterUtil.h"
+#include "MediaTransporterParam.h"
#include <algorithm>
util::throwIfFeatureNotSupported(util::MTPR_FEATURE_CAMERA);
util::throwIfNotPrivileged(util::MTPR_PRIVILEGE_CAMERA);
- parseSourceParam(params);
-}
-
-void MediaSourceBinCamera::parseSourceParam(bundle* params)
-{
- int written_count = 0;
- char* string_val = NULL;
-
- RET_IF(!params, "input param is NULL");
-
- if (bundle_get_str(params, MTPR_SOURCE_PARAM_VIDEO_WIDTH, &string_val) != BUNDLE_ERROR_KEY_NOT_AVAILABLE) {
- _videoInfo.width = static_cast<int>(strtoul(string_val, NULL, 10));
- LOG_DEBUG("Source param video width %u", _videoInfo.width);
- written_count++;
- }
-
- if (bundle_get_str(params, MTPR_SOURCE_PARAM_VIDEO_HEIGHT, &string_val) != BUNDLE_ERROR_KEY_NOT_AVAILABLE) {
- _videoInfo.height = static_cast<int>(strtoul(string_val, NULL, 10));
- LOG_DEBUG("Source param video height %u", _videoInfo.height);
- written_count++;
- }
-
- if (bundle_get_str(params, MTPR_SOURCE_PARAM_VIDEO_FRAMERATE, &string_val) != BUNDLE_ERROR_KEY_NOT_AVAILABLE) {
- _videoInfo.frameRate = static_cast<int>(strtoul(string_val, NULL, 10));
- LOG_DEBUG("Source param video framerate %u", _videoInfo.frameRate);
- written_count++;
- }
-
- if (bundle_get_str(params, MTPR_ENCODING_PARAM_BITRATE, &string_val) != BUNDLE_ERROR_KEY_NOT_AVAILABLE) {
- _encInfo.bitrate = (guint)strtoul(string_val, NULL, 10);
- LOG_DEBUG("Encoder target bitrate %u", _encInfo.bitrate);
- written_count++;
- }
-
- if (written_count == 0)
- throw MediaTransporterException(MTPR_ERROR_INVALID_OPERATION, "Failed to parse Source Param");
+ param::parseSourceParam(params, &_videoInfo, &_encInfo);
}
GstElement* MediaSourceBinCamera::createCameraSource()
try {
elements.push_back(createCameraSource());
- auto created = createVideoRestOfElements(MediaTransporterIni::get().mediaSource(static_cast<int>(MTPR_SOURCE_TYPE_CAMERA))); // FIXME
+ auto created = createVideoRestOfElements(MediaTransporterIni::get().mediaSource(static_cast<int>(MTPR_SOURCE_TYPE_CAMERA)));
std::copy(created.begin(), created.end(), std::back_inserter(elements));
setSourceParam(elements);
#include "MediaTransporterException.h"
#include "MediaTransporterParseIni.h"
#include "MediaTransporterUtil.h"
+#include "MediaTransporterParam.h"
#include <sound_manager_internal.h>
#include <pulse/proplist.h>
util::throwIfFeatureNotSupported(util::MTPR_FEATURE_MICROPHONE);
util::throwIfNotPrivileged(util::MTPR_PRIVILEGE_RECORDER);
- parseSourceParam(params);
-}
-
-void MediaSourceBinMic::parseSourceParam(bundle* params)
-{
- int written_count = 0;
- char* string_val = NULL;
-
- RET_IF(!params, "input param is NULL");
-
- /* Will be move to mic/audiotest bin */
- if (bundle_get_str(params, MTPR_SOURCE_PARAM_AUDIO_CHANNEL, &string_val) != BUNDLE_ERROR_KEY_NOT_AVAILABLE) {
- _audioInfo.channel = static_cast<int>(strtoul(string_val, NULL, 10));
- LOG_DEBUG("Source param audio channel %u", _audioInfo.channel);
- written_count++;
- }
-
- if (bundle_get_str(params, MTPR_SOURCE_PARAM_AUDIO_RATE, &string_val) != BUNDLE_ERROR_KEY_NOT_AVAILABLE) {
- _audioInfo.rate = static_cast<int>(strtoul(string_val, NULL, 10));
- LOG_DEBUG("Source param audio rate %u", _audioInfo.rate);
- written_count++;
- }
-
- if (bundle_get_str(params, MTPR_SOURCE_PARAM_AUDIO_FORMAT, &string_val) != BUNDLE_ERROR_KEY_NOT_AVAILABLE) {
- _audioInfo.format = string_val;
- LOG_DEBUG("Source param audio format %s", _audioInfo.format.c_str());
- written_count++;
- }
-
- if (bundle_get_str(params, MTPR_ENCODING_PARAM_BITRATE, &string_val) != BUNDLE_ERROR_KEY_NOT_AVAILABLE) {
- _encInfo.bitrate = (guint)strtoul(string_val, NULL, 10);
- LOG_DEBUG("Encoder target bitrate %u", _encInfo.bitrate);
- written_count++;
- }
-
- if (written_count == 0)
- throw MediaTransporterException(MTPR_ERROR_INVALID_OPERATION, "Failed to parse Source Param");
+ param::parseSourceParam(params, &_audioInfo, &_encInfo);
}
GstElement* MediaSourceBinMic::createMicSource()
#include "MediaTransporterLog.h"
#include "MediaTransporterException.h"
#include "MediaTransporterParseIni.h"
+#include "MediaTransporterParam.h"
#include <algorithm>
MediaSourceBinVideoTest::MediaSourceBinVideoTest(bundle* params)
{
- parseSourceParam(params);
-}
-
-void MediaSourceBinVideoTest::parseSourceParam(bundle* params)
-{
- int written_count = 0;
- char* string_val = NULL;
-
- RET_IF(!params, "input param is NULL");
-
- if (bundle_get_str(params, MTPR_SOURCE_PARAM_VIDEO_WIDTH, &string_val) != BUNDLE_ERROR_KEY_NOT_AVAILABLE) {
- _videoInfo.width = static_cast<int>(strtoul(string_val, NULL, 10));
- LOG_DEBUG("Source param video width %u", _videoInfo.width);
- written_count++;
- }
-
- if (bundle_get_str(params, MTPR_SOURCE_PARAM_VIDEO_HEIGHT, &string_val) != BUNDLE_ERROR_KEY_NOT_AVAILABLE) {
- _videoInfo.height = static_cast<int>(strtoul(string_val, NULL, 10));
- LOG_DEBUG("Source param video height %u", _videoInfo.height);
- written_count++;
- }
-
- if (bundle_get_str(params, MTPR_SOURCE_PARAM_VIDEO_FRAMERATE, &string_val) != BUNDLE_ERROR_KEY_NOT_AVAILABLE) {
- _videoInfo.frameRate = static_cast<int>(strtoul(string_val, NULL, 10));
- LOG_DEBUG("Source param video framerate %u", _videoInfo.frameRate);
- written_count++;
- }
-
- if (bundle_get_str(params, MTPR_ENCODING_PARAM_BITRATE, &string_val) != BUNDLE_ERROR_KEY_NOT_AVAILABLE) {
- _encInfo.bitrate = (guint)strtoul(string_val, NULL, 10);
- LOG_DEBUG("Encoder target bitrate %u", _encInfo.bitrate);
- written_count++;
- }
-
- if (written_count == 0)
- throw MediaTransporterException(MTPR_ERROR_INVALID_OPERATION, "Failed to parse Source Param");
+ param::parseSourceParam(params, &_videoInfo, &_encInfo);
}
GstElement* MediaSourceBinVideoTest::createVideoTestSource()
--- /dev/null
+/*
+ * Copyright (c) 2022 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <iostream>
+#include <string>
+#include <algorithm>
+#include "mtpr.h"
+#include "MediaTransporterParam.h"
+#include "MediaTransporterException.h"
+#include "MediaTransporterLog.h"
+
+using namespace tizen_media_transporter;
+
+void param::parseSourceParam(bundle* params, param::videoInfo* vInfo, param::encodingInfo* eInfo)
+{
+ int written_count = 0;
+ char* string_val = NULL;
+
+ RET_IF(!params, "input param is NULL");
+
+ if (bundle_get_str(params, MTPR_SOURCE_PARAM_VIDEO_WIDTH, &string_val) != BUNDLE_ERROR_KEY_NOT_AVAILABLE) {
+ vInfo->width = static_cast<int>(strtoul(string_val, NULL, 10));
+ LOG_DEBUG("Source param video width %u", vInfo->width);
+ written_count++;
+ }
+
+ if (bundle_get_str(params, MTPR_SOURCE_PARAM_VIDEO_HEIGHT, &string_val) != BUNDLE_ERROR_KEY_NOT_AVAILABLE) {
+ vInfo->height = static_cast<int>(strtoul(string_val, NULL, 10));
+ LOG_DEBUG("Source param video height %u", vInfo->height);
+ written_count++;
+ }
+
+ if (bundle_get_str(params, MTPR_SOURCE_PARAM_VIDEO_FRAMERATE, &string_val) != BUNDLE_ERROR_KEY_NOT_AVAILABLE) {
+ vInfo->frameRate = static_cast<int>(strtoul(string_val, NULL, 10));
+ LOG_DEBUG("Source param video framerate %u", vInfo->frameRate);
+ written_count++;
+ }
+
+ if (bundle_get_str(params, MTPR_ENCODING_PARAM_BITRATE, &string_val) != BUNDLE_ERROR_KEY_NOT_AVAILABLE) {
+ eInfo->bitrate = (guint)strtoul(string_val, NULL, 10);
+ LOG_DEBUG("Encoder target bitrate %u", eInfo->bitrate);
+ written_count++;
+ }
+
+ if (written_count == 0)
+ throw MediaTransporterException(MTPR_ERROR_INVALID_OPERATION, "Failed to parse Source Param");
+}
+
+void param::parseSourceParam(bundle* params, param::audioInfo* aInfo, param::encodingInfo* eInfo)
+{
+ int written_count = 0;
+ char* string_val = NULL;
+
+ RET_IF(!params, "input param is NULL");
+
+ /* Will be move to mic/audiotest bin */
+ if (bundle_get_str(params, MTPR_SOURCE_PARAM_AUDIO_CHANNEL, &string_val) != BUNDLE_ERROR_KEY_NOT_AVAILABLE) {
+ aInfo->channel = static_cast<int>(strtoul(string_val, NULL, 10));
+ LOG_DEBUG("Source param audio channel %u", aInfo->channel);
+ written_count++;
+ }
+
+ if (bundle_get_str(params, MTPR_SOURCE_PARAM_AUDIO_RATE, &string_val) != BUNDLE_ERROR_KEY_NOT_AVAILABLE) {
+ aInfo->rate = static_cast<int>(strtoul(string_val, NULL, 10));
+ LOG_DEBUG("Source param audio rate %u", aInfo->rate);
+ written_count++;
+ }
+
+ if (bundle_get_str(params, MTPR_SOURCE_PARAM_AUDIO_FORMAT, &string_val) != BUNDLE_ERROR_KEY_NOT_AVAILABLE) {
+ aInfo->format = string_val;
+ LOG_DEBUG("Source param audio format %s", aInfo->format.c_str());
+ written_count++;
+ }
+
+ if (bundle_get_str(params, MTPR_ENCODING_PARAM_BITRATE, &string_val) != BUNDLE_ERROR_KEY_NOT_AVAILABLE) {
+ eInfo->bitrate = (guint)strtoul(string_val, NULL, 10);
+ LOG_DEBUG("Encoder target bitrate %u", eInfo->bitrate);
+ written_count++;
+ }
+
+ if (written_count == 0)
+ throw MediaTransporterException(MTPR_ERROR_INVALID_OPERATION, "Failed to parse Source Param");
+}
if (ret != MEDIA_PACKET_ERROR_NONE)
LOG_ERROR("failed to media_packet_set_codec_data()");
else
- LOG_DEBUG("codec_data[%p, size:%" G_GSIZE_FORMAT "] is set to the media packet[%p]",
+ LOG_VERBOSE("codec_data[%p, size:%" G_GSIZE_FORMAT "] is set to the media packet[%p]",
buff_info.data, buff_info.size, packet);
gst_buffer_unmap(codec_data, &buff_info);
display_sub_basic();
} else if (g_menu_state == CURRENT_STATUS_CONNECTION_TYPE) {
g_print("*** Input connection type.\n\
- (1:RIST_SENDER, 2:RIST_RECEIVER, 3:SRT_SENDER, 4:SRT_RECEIVER, 5:RTSP_SENDER, 6:RTSP_SENDER_TO_SERVER)\n");
+ (0:RIST_SENDER, 1:RIST_RECEIVER, 2:SRT_SENDER, 3:SRT_RECEIVER, 4:RTSP_SENDER, 5:RTSP_SENDER_TO_SERVER)\n");
} else if (g_menu_state == CURRENT_STATUS_SENDER_ADDRESS) {
g_print("*** Input sender address:\n");
} else if (g_menu_state == CURRENT_STATUS_RECEIVER_ADDRESS) {
break;
case CURRENT_STATUS_CONNECTION_TYPE: {
value = atoi(cmd);
- _mtpr_test_create(value - 1);
+ _mtpr_test_create(value);
reset_menu_state();
break;
}