- Two new subclasses, MediaTransporterDisplayOverlay and MediaTransporterDisplayEvas,
are introduced to handle specific display types.
- The MediaTransporterDisplayFactory class has been added to manage
the creation of MediaTransporterDisplay instances based on the display type
provided as an argument.
Change-Id: I7d33f2671a76daeb33e0003799b1df7fa2dd6038
#include <gst/gst.h>
#include "MediaTransporter.h"
-#include "MediaTransporterObserver.h"
#ifdef __cplusplus
extern "C" {
MediaTransporterDisplay(mtprDisplayType type, void *surface);
~MediaTransporterDisplay();
- GstElement* videoSink();
+ virtual GstElement* createVideoSink() = 0;
mtprDisplayType getType() { return _type; };
mm_display_interface_h getMmDisplayHandle() { std::lock_guard<std::mutex> mutex(_mutex); return _mmDisplay; }
-private:
- void applyVisibleProperty();
- void applyModeProperty();
+protected:
+ virtual void applyVisibleProperty() = 0;
+ virtual void applyModeProperty() = 0;
mtprDisplayType _type;
void* _surface;
--- /dev/null
+/*
+* Copyright (c) 2024 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_DISPLAY_EVAS_H__
+#define __TIZEN_MEDIA_TRANSPORTER_DISPLAY_EVAS_H__
+
+#include "MediaTransporter.h"
+#include "MediaTransporterDisplay.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+namespace tizen_media_transporter {
+
+class MediaTransporterDisplayEvas : public MediaTransporterDisplay {
+public:
+ MediaTransporterDisplayEvas(void *surface)
+ : MediaTransporterDisplay(mtprDisplayType::MTPR_DISPLAY_TYPE_EVAS, surface) {};
+ ~MediaTransporterDisplayEvas() = default;
+
+ GstElement* createVideoSink() override;
+
+private:
+ void applyVisibleProperty() override;
+ void applyModeProperty() override;
+};
+
+} // namespace tizen_media_transporter
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* __TIZEN_MEDIA_TRANSPORTER_DISPLAY_EVAS_H__ */
--- /dev/null
+/*
+* Copyright (c) 2024 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_DISPLAY_FACTORY_H__
+#define __TIZEN_MEDIA_TRANSPORTER_DISPLAY_FACTORY_H__
+
+#include "MediaTransporter.h"
+#include "MediaTransporterDisplay.h"
+#include "MediaTransporterException.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+namespace tizen_media_transporter {
+
+class MediaTransporterDisplayFactory
+{
+public:
+ static MediaTransporterDisplay* create(mtprDisplayType type, void *surface);
+
+};
+
+} // namespace tizen_media_transporter
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* __TIZEN_MEDIA_TRANSPORTER_DISPLAY_FACTORY_H__ */
--- /dev/null
+/*
+* Copyright (c) 2024 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_DISPLAY_OVERAY_H__
+#define __TIZEN_MEDIA_TRANSPORTER_DISPLAY_OVERAY_H__
+
+#include "MediaTransporter.h"
+#include "MediaTransporterDisplay.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+namespace tizen_media_transporter {
+
+class MediaTransporterDisplayOverlay : public MediaTransporterDisplay {
+public:
+ MediaTransporterDisplayOverlay(void *surface)
+ : MediaTransporterDisplay(mtprDisplayType::MTPR_DISPLAY_TYPE_OVERLAY, surface) {};
+ ~MediaTransporterDisplayOverlay() = default;
+
+ GstElement* createVideoSink() override;
+
+private:
+ void applyVisibleProperty() override;
+ void applyModeProperty() override;
+};
+
+} // namespace tizen_media_transporter
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* __TIZEN_MEDIA_TRANSPORTER_DISPLAY_OVERAY_H__ */
Name: capi-media-transporter
Summary: A Media Transporter library in Tizen Native API
-Version: 1.2.2
+Version: 1.2.3
Release: 0
Group: Multimedia/API
License: Apache-2.0
void MediaSourceAudio::setSourceAudioFormat(mtprSourceAudioFormat format)
{
- switch (format)
- {
+ switch (format) {
case MTPR_SOURCE_AUDIO_FORMAT_S16LE:
_audioInfo.format = "S16LE";
break;
IMediaSourceBin* MediaSourceBinFactory::create(mtprSourceType type)
{
- switch (type)
- {
+ switch (type) {
case MTPR_SOURCE_TYPE_VIDEOTEST:
return static_cast<IMediaSourceBin*>(new MediaSourceBinVideoTest());
case MTPR_SOURCE_TYPE_AUDIOTEST:
#include "MediaTransporterLog.h"
#include "MediaTransporterFactory.h"
#include "MediaSourceBinFactory.h"
+#include "MediaTransporterDisplayFactory.h"
#include "MediaSourceBinBase.h"
#include "MediaSourceAudio.h"
#include "MediaSourceVideo.h"
RET_VAL_IF(!receiver, MTPR_ERROR_INVALID_OPERATION, "only receiver support this api!!!");
try {
- handle->display = std::make_shared<MediaTransporterDisplay>(type, display);
+ handle->display = std::shared_ptr<MediaTransporterDisplay>(
+ MediaTransporterDisplayFactory::create(static_cast<mtprDisplayType>(type), display));
receiver->setDisplay(handle->display);
} catch (const MediaTransporterException& e) {
LOG_ERROR("Failed to set display!!! : %s", e.what());
#include "MediaTransporterDisplay.h"
#include "MediaTransporterException.h"
#include "MediaTransporterLog.h"
-#include "MediaTransporterParseIni.h"
-#include "MediaTransporterGst.h"
using namespace tizen_media_transporter;
LOG_DEBUG("dtor: %p", this);
}
-GstElement* MediaTransporterDisplay::videoSink()
-{
- std::lock_guard<std::mutex> mutex(_mutex);
- mm_display_type_e displayType = MM_DISPLAY_TYPE_NONE;
- try {
- std::string videoSinkName;
-
- switch (_type) {
- case MTPR_DISPLAY_TYPE_OVERLAY:
- displayType = MM_DISPLAY_TYPE_OVERLAY;
- videoSinkName = MediaTransporterIni::get().renderingSink().videoSinkElement;
- LOG_INFO("it's OVERLAY type");
- break;
- case MTPR_DISPLAY_TYPE_EVAS:
- LOG_INFO("it's EVAS type");
- displayType = MM_DISPLAY_TYPE_EVAS;
- videoSinkName = gst::DEFAULT_ELEMENT_FAKESINK;
- break;
- default:
- LOG_ERROR_IF_REACHED("type(%d)", _type);
- throw MediaTransporterException(MTPR_ERROR_INVALID_PARAMETER, "_display is NULL");
- }
-
- _sinkElement = gst::_createElement(videoSinkName);
-
- int overlaySurfaceId = -1;
- if (mm_display_interface_set_display_mainloop_sync(_mmDisplay, displayType, _surface, &overlaySurfaceId) != MM_ERROR_NONE)
- throw MediaTransporterException(MTPR_ERROR_INVALID_OPERATION, "failed to mm_display_interface_set_display_mainloop_sync()");
-
- applyModeProperty();
- applyVisibleProperty();
-
- LOG_INFO("surface[%p], got overlaySurfaceId[%d]", _surface, overlaySurfaceId);
- if (_type == MTPR_DISPLAY_TYPE_OVERLAY)
- gst_video_overlay_set_wl_window_wl_surface_id(GST_VIDEO_OVERLAY(_sinkElement), overlaySurfaceId);
-
- return GST_ELEMENT(gst_object_ref(_sinkElement));
- } catch (const MediaTransporterException& e) {
- if (_sinkElement) {
- gst_object_unref(_sinkElement);
- _sinkElement = nullptr;
- }
- throw;
- }
-}
-
void MediaTransporterDisplay::setVisible(bool visible)
{
std::lock_guard<std::mutex> mutex(_mutex);
if (_sinkElement)
applyModeProperty();
}
-
-void MediaTransporterDisplay::applyVisibleProperty()
-{
- if (_type == MTPR_DISPLAY_TYPE_OVERLAY) {
- if (g_object_class_find_property(G_OBJECT_GET_CLASS(G_OBJECT(_sinkElement)), "visible"))
- g_object_set(G_OBJECT(_sinkElement),
- "visible", _visible, NULL);
- } else {
- int ret = mm_display_interface_evas_set_visible(_mmDisplay, _visible);
- if (ret != MM_ERROR_NONE)
- LOG_ERROR("mm_display_interface_evas_set_visible failed 0x%x", ret);
- }
-}
-
-void MediaTransporterDisplay::applyModeProperty()
-{
- if (_type == MTPR_DISPLAY_TYPE_OVERLAY) {
- if (g_object_class_find_property(G_OBJECT_GET_CLASS(G_OBJECT(_sinkElement)), "display-geometry-method"))
- g_object_set(G_OBJECT(_sinkElement),
- "display-geometry-method", (gint)_mode, /* 0: letter box, 1: origin size, 2: full screen */
- NULL);
- } else {
- int ret = mm_display_interface_evas_set_mode(_mmDisplay, static_cast<int>(_mode));
- if (ret != MM_ERROR_NONE)
- LOG_ERROR("mm_display_interface_evas_set_mode failed 0x%x", ret);
- }
-}
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright (c) 2024 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 <mm_error.h>
+
+#include "MediaTransporter.h"
+#include "MediaTransporterDisplayEvas.h"
+#include "MediaTransporterException.h"
+#include "MediaTransporterLog.h"
+#include "MediaTransporterGst.h"
+
+using namespace tizen_media_transporter;
+
+GstElement* MediaTransporterDisplayEvas::createVideoSink()
+{
+ std::lock_guard<std::mutex> mutex(_mutex);
+ try {
+ _sinkElement = gst::_createElement(gst::DEFAULT_ELEMENT_FAKESINK);
+
+ if (mm_display_interface_set_display_mainloop_sync(_mmDisplay, MM_DISPLAY_TYPE_EVAS, _surface, nullptr) != MM_ERROR_NONE)
+ throw MediaTransporterException(MTPR_ERROR_INVALID_OPERATION, "failed to mm_display_interface_set_display_mainloop_sync()");
+
+ applyModeProperty();
+ applyVisibleProperty();
+
+ LOG_INFO("surface[%p]", _surface);
+ return GST_ELEMENT(gst_object_ref(_sinkElement));
+ } catch (const MediaTransporterException& e) {
+ if (_sinkElement) {
+ gst_object_unref(_sinkElement);
+ _sinkElement = nullptr;
+ }
+ throw;
+ }
+}
+
+void MediaTransporterDisplayEvas::applyVisibleProperty()
+{
+ int ret = mm_display_interface_evas_set_visible(_mmDisplay, _visible);
+ if (ret != MM_ERROR_NONE)
+ LOG_ERROR("mm_display_interface_evas_set_visible failed 0x%x", ret);
+}
+
+void MediaTransporterDisplayEvas::applyModeProperty()
+{
+ int ret = mm_display_interface_evas_set_mode(_mmDisplay, static_cast<int>(_mode));
+ if (ret != MM_ERROR_NONE)
+ LOG_ERROR("mm_display_interface_evas_set_mode failed 0x%x", ret);
+}
--- /dev/null
+/*
+* Copyright (c) 2024 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 "MediaTransporter.h"
+#include "MediaTransporterLog.h"
+#include "MediaTransporterDisplayOverlay.h"
+#include "MediaTransporterDisplayEvas.h"
+#include "MediaTransporterDisplayFactory.h"
+#include "MediaTransporterException.h"
+
+using namespace tizen_media_transporter;
+
+MediaTransporterDisplay* MediaTransporterDisplayFactory::create(mtprDisplayType type, void *surface)
+{
+ try {
+ switch (type) {
+ case MTPR_DISPLAY_TYPE_OVERLAY:
+ return new MediaTransporterDisplayOverlay(surface);
+ case MTPR_DISPLAY_TYPE_EVAS:
+ return new MediaTransporterDisplayEvas(surface);
+ default:
+ throw MediaTransporterException(MTPR_ERROR_INVALID_PARAMETER, "Invalid display type");
+ }
+ } catch (const MediaTransporterException& e) {
+ LOG_ERROR("%s", e.what());
+ throw;
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2024 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 <mm_error.h>
+#include <gst/video/videooverlay.h>
+
+#include "MediaTransporter.h"
+#include "MediaTransporterDisplayOverlay.h"
+#include "MediaTransporterException.h"
+#include "MediaTransporterLog.h"
+#include "MediaTransporterParseIni.h"
+#include "MediaTransporterGst.h"
+
+using namespace tizen_media_transporter;
+
+GstElement* MediaTransporterDisplayOverlay::createVideoSink()
+{
+ std::lock_guard<std::mutex> mutex(_mutex);
+ try {
+ _sinkElement = gst::_createElement(MediaTransporterIni::get().renderingSink().videoSinkElement);
+
+ int overlaySurfaceId = -1;
+ if (mm_display_interface_set_display_mainloop_sync(_mmDisplay, MM_DISPLAY_TYPE_OVERLAY, _surface, &overlaySurfaceId) != MM_ERROR_NONE)
+ throw MediaTransporterException(MTPR_ERROR_INVALID_OPERATION, "failed to mm_display_interface_set_display_mainloop_sync()");
+
+ applyModeProperty();
+ applyVisibleProperty();
+
+ LOG_INFO("surface[%p], got overlaySurfaceId[%d]", _surface, overlaySurfaceId);
+ gst_video_overlay_set_wl_window_wl_surface_id(GST_VIDEO_OVERLAY(_sinkElement), overlaySurfaceId);
+
+ return GST_ELEMENT(gst_object_ref(_sinkElement));
+ } catch (const MediaTransporterException& e) {
+ if (_sinkElement) {
+ gst_object_unref(_sinkElement);
+ _sinkElement = nullptr;
+ }
+ throw;
+ }
+}
+
+void MediaTransporterDisplayOverlay::applyVisibleProperty()
+{
+ if (g_object_class_find_property(G_OBJECT_GET_CLASS(G_OBJECT(_sinkElement)), "visible"))
+ g_object_set(G_OBJECT(_sinkElement),
+ "visible", _visible, NULL);
+}
+
+void MediaTransporterDisplayOverlay::applyModeProperty()
+{
+ if (g_object_class_find_property(G_OBJECT_GET_CLASS(G_OBJECT(_sinkElement)), "display-geometry-method"))
+ g_object_set(G_OBJECT(_sinkElement),
+ "display-geometry-method", (gint)_mode, /* 0: letter box, 1: origin size, 2: full screen */
+ NULL);
+}
MediaTransporterBase* MediaTransporterFactory::create(mtprConnectionType type)
{
- switch (type)
- {
+ switch (type) {
case MTPR_CONNECTION_TYPE_RIST_SENDER:
return static_cast<MediaTransporterBase*>(new MediaTransporterSenderRist());
case MTPR_CONNECTION_TYPE_RIST_RECEIVER:
bool param::srt::_isValidKeyLength(int keyLen)
{
- switch (keyLen)
- {
+ switch (keyLen) {
case MTPR_CONNECTION_SRT_NO_KEY:
case MTPR_CONNECTION_SRT_KEY_LEN_16:
case MTPR_CONNECTION_SRT_KEY_LEN_24:
_resourceManager->acquire(RES_TYPE_VIDEO_OVERLAY);
converter = gst::_createElement(gst::DEFAULT_ELEMENT_VIDEOCONVERT);
elements.push_back(converter);
- sink = _display->videoSink();
+ sink = _display->createVideoSink();
elements.push_back(sink);
} catch (const MediaTransporterException& e) {
if (converter) {
char* tmp = new char[1000000];
- switch (_type)
- {
+ switch (_type) {
case MEDIA_TYPE_ENCODED_VIDEO:
size = videobytestream2nalunit(tmp);
ptsOffset = ES_DEFAULT_VIDEO_PTS_OFFSET;