}
static const std::string GetMediaType(const Track& track) {
- std::string media_type =
- track.streamtype.empty() ? track.mimetype : track.streamtype;
- if (media_type.find("_tz") != std::string::npos) {
- media_type = media_type.substr(0, media_type.size() - 3);
- }
- return media_type;
+ return track.streamtype.empty() ?
+ track.mimetype : track.streamtype;
}
static const std::string GetCapsName(const std::string media_type,
gst_buffer_unref(codec_data);
}
-static void FillSecureField(const GstCapsWrapper& caps, const Track& track) {
- if (track.mimetype.find("_tz") == std::string::npos) return;
- caps.SetValue("secure", G_TYPE_BOOLEAN, TRUE);
-}
-
static void FillChannelMaskField(const GstCapsWrapper& caps,
const Track& track) {
GstAudioChannelPosition position[64];
internal::FillCodecData(caps, track);
internal::FillStreamFormat(caps, track);
internal::FillDrmInfo(caps, track);
- internal::FillSecureField(caps, track);
internal::FillChannelMaskField(caps, track);
caps.PrintCapsString();
FillDefaultValue_(caps, track);
internal::FillStreamType(caps, track);
internal::FillCodecData(caps, track);
-
internal::FillStreamFormat(caps, track);
-
- internal::FillSecureField(caps, track);
internal::FillChannelMaskField(caps, track);
caps.PrintCapsString();
+++ /dev/null
-/*
- * Copyright (c) 2023 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 "trackrenderer/core/pipeline.hpp"
-
-#include <dlfcn.h>
-
-#include <cassert>
-
-namespace plusplayer {
-
-namespace trackrenderer {
-
-namespace trustzone {
-
-#define GSTREAMER_PLUGIN_LIB(NAME) "/usr/lib/gstreamer-1.0/" #NAME
-
-static std::once_flag lib_loaded;
-static void* tzappsrc_lib = nullptr;
-using TzAppsrcPushBuffer = int(*)(void* appsrc, void* buffer);
-static TzAppsrcPushBuffer tz_appsrc_push_buffer;
-
-bool InitTzAppsrc() {
- bool retval = true;
- auto loadlib = [](bool& ret) {
- tzappsrc_lib = dlopen(GSTREAMER_PLUGIN_LIB(libgsttzappsrc.so), RTLD_LAZY);
- if (!tzappsrc_lib) {
- TRACKRENDERER_ERROR("libgsttzappsrc.so open failed: %s", dlerror());
- assert(0);
- ret = false;
- return;
- }
- tz_appsrc_push_buffer =
- (TzAppsrcPushBuffer)dlsym(tzappsrc_lib, "gst_tz_app_src_push_buffer");
- if (!tz_appsrc_push_buffer) {
- TRACKRENDERER_ERROR("Failed to import gst_tz_app_src_push_buffer");
- assert(0);
- ret = false;
- return;
- }
- };
- std::call_once(lib_loaded, loadlib, retval);
- return retval;
-}
-
-bool GstAppsrcPushBuffer(GstElement* appsrc, GstBuffer* buffer) {
- if(tz_appsrc_push_buffer(appsrc,buffer) != GST_FLOW_OK) {
- return false;
- }
- return true;
-}
-
-} // namespace trustzone
-
-} // namespace trackrenderer
-
-} // namespace plusplayer
const char kVideoSinkName[] = "tizenwlsink";
const char kAudioSinkName[] = "pulsesink";
-// Hw clock
-#ifndef PR_TASK_PERF_USER_TRACE
-#define PR_TASK_PERF_USER_TRACE 666
-#endif
-
-constexpr int kBufSize = 256;
-inline void PerfUsrTrace(const char* arg = nullptr) {
- char buf[kBufSize]{
- 0,
- };
- const char* prefix_str = "[PERF][MMPLAYER]";
- bool use_arg{false};
- if (arg) {
- if (strlen(arg) < (kBufSize - strlen(prefix_str))) {
- use_arg = true;
- }
- }
- snprintf(buf, kBufSize, "%s %s", prefix_str, (use_arg ? arg : ""));
- prctl(PR_TASK_PERF_USER_TRACE, buf, strlen(buf));
-}
-
} // namespace
namespace plusplayer {
return TrackEncryptionUnit::kNone;
}
-inline bool IsFhdOrLowerResolution(int width, int height, int max_w,
- int max_h) {
- int w = max_w ? max_w : width;
- int h = max_h ? max_h : height;
- if ((w <= kMaxFhdWidth && h <= kMaxFhdHeight) ||
- (w <= kMaxFhdHeight && h <= kMaxFhdWidth))
- return true;
- TRACKRENDERER_ERROR("w:%d, h:%d, mw:%d, mh:%d!", width, height, max_w, max_h);
- return false;
-}
-
-inline bool IsUhdResolution(int w, int h) {
- return ((w > kMaxFhdWidth || h > kMaxFhdHeight) &&
- (w <= kMaxUhdWidth && h <= kMaxUhdHeight));
-}
-
-inline bool IsUhd8kResolution(int w, int h) {
- return (w > kMaxUhdWidth || h > kMaxUhdHeight);
-}
-
-inline bool IsTzMimeType(const std::string& mimetype) { // useful when external
- // audio is present in
- // verimatrix case as trustzone is not used in this case
- return (mimetype.find("_tz") != std::string::npos);
-}
-
inline bool IsExternalDecryptionCase(const drm::Property& property) {
return property.external_decryption;
}
-inline bool IsTzAppSrcElementNecessary(const drm::Property& property,
- const std::string& mimetype) {
- return IsTzMimeType(mimetype);
-}
-
inline bool IsDrmEmeElementNecessary(const drm::Property& property,
const std::string& mimetype) {
// Some Apps call setDrm even for plain content (mostly trailers),
// but main contents are Drm protected. So we need to check drm_type
// as well as mime_type for plain/drm content. (Example app: Stan/Chili)
- return (GetTrackEncryptionUnit(property.type) == TrackEncryptionUnit::kEs &&
- IsTzMimeType(mimetype));
+ return (GetTrackEncryptionUnit(property.type) == TrackEncryptionUnit::kEs);
}
inline bool IsDecryptorElementNecessary(const drm::Property& property) {
return (property.type == drm::Type::kClearkey);
}
-inline bool IsTzDecoderElementNecessary(const drm::Property& property,
- const std::string& mimetype) {
- return IsTzMimeType(mimetype);
-}
inline bool IsDecoderElementNecessary(const std::string& mimetype) {
return !IsPcmMimeType(mimetype);
if (!pipeline_) {
return false;
}
- /*
- if(still_mode_type_ == StillMode::kOff) {
- pipeline_->SetProperty(Elements::kSinkVideo, "still-mode", FALSE);
- }
- */
+
if (state_ < State::kWorking) return false;
target_substate_ = SubState::kPlaying;
pipeline_->SetState(Elements::kPipeline, GST_STATE_PLAYING);
TRACKRENDERER_LEAVE;
return true;
}
- /*
- if(still_mode_type_ == StillMode::kOn) {
- pipeline_->SetProperty(Elements::kSinkVideo, "still-mode", TRUE);
- }
- */
+
TRACKRENDERER_INFO("Set pipeline state to GST_STATE_NULL.");
pipeline_->SetState(Elements::kPipeline, GST_STATE_NULL);
ReleaseResource_();
if (!pipeline_) {
return false;
}
- // mute off/on values are defined in mmaudiosink element
- static const int mute_off = 2;
- static const int mute_on = 3;
// get user setting
bool is_mute = false;
pipeline_->GetProperty(Elements::kSinkAudio, "mute", &is_mute);
- int mute_flag = is_mute ? mute_on : mute_off;
-
gboolean async = TRUE;
if (playback_rate != kDefaultPlaybackRate) {
- mute_flag = mute_on;
+ is_mute = true;
async = FALSE;
}
auto is_audio_track = [](const Track& item) noexcept -> bool {
return item.mimetype.find("audio") != std::string::npos;
};
+
auto target = find_if(trackinfo_.begin(), trackinfo_.end(), is_audio_track);
if (target != trackinfo_.end()) {
- pipeline_->SetProperty(Elements::kSinkAudio, "mute", mute_flag % 2,
- "async", async);
+ pipeline_->SetProperty(Elements::kSinkAudio, "mute", is_mute, "async", async);
}
gint64 start = time_converter_->timeToNs_(time), stop = GST_CLOCK_TIME_NONE;
return type;
}
-bool TrackRenderer::SetMatroskaColorInfo(const std::string& color_info) {
- TRACKRENDERER_ENTER;
- std::unique_lock<std::mutex> lock(resource_m_);
- if (state_ == State::kStopped) return false;
- if (pipeline_ == nullptr) return false;
- GstCaps* old_caps = nullptr;
- pipeline_->GetProperty(Elements::kAppSrcVideo, "caps", &old_caps);
- if (old_caps == nullptr) return false;
- auto old_caps_guard = gstguard::make_guard(old_caps);
- auto new_caps_guard = gstguard::make_guard(gst_caps_copy(old_caps));
- gst_caps_set_simple(new_caps_guard.get(), "matroska_color_info",
- G_TYPE_STRING, color_info.c_str(), nullptr);
- pipeline_->SetProperty(Elements::kSinkVideo, "video-color-info",
- new_caps_guard.get());
- pipeline_->SetProperty(Elements::kAppSrcVideo, "caps", new_caps_guard.get());
- return true;
-}
-
void TrackRenderer::CreateAppSrc_(TrackType type, const GstCaps* caps) {
TRACKRENDERER_ENTER;
return;
}
if (strstr(sink_name, kAudioSinkName)) {
- pipeline_->SetProperty(Elements::kSinkAudio, "volume", (volume_/100.0));
+ pipeline_->SetProperty(Elements::kSinkAudio, "volume", (volume_ / 100.0));
} else {
TRACKRENDERER_WARN("unknown audio sink name: %s", sink_name);
}
pipeline_->BinRemove(Elements::kBinAudio, Elements::kDecAudio,
Elements::kSinkAudio);
std::string sink_name = kFakeSinkName;
- if (internal::IsTzMimeType(track.mimetype)) {
- sink_name = "tzfakesink";
- }
pipeline_->FactoryMake(Elements::kFakeSinkAudio, sink_name.c_str(), NULL);
pipeline_->SetProperty(Elements::kFakeSinkAudio, "async", TRUE, NULL);