Skip to content
34 changes: 26 additions & 8 deletions common/source/LinuxUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,23 @@ constexpr gid_t kNoGroupChange = -1; // -1 means chown() won't change the group
uid_t getFileOwnerId(const std::string &fileOwner)
{
uid_t ownerId = kNoOwnerChange;
const size_t kBufferSize = sysconf(_SC_GETPW_R_SIZE_MAX);
if (!fileOwner.empty() && kBufferSize > 0)
long buffersize = sysconf(_SC_GETPW_R_SIZE_MAX);
size_t BufferSize = 0;
if (buffersize == -1)
{
RIALTO_COMMON_LOG_SYS_WARN(errno, "Invalid Buffer Size '%s'", fileOwner.c_str());
}
if (buffersize > 0)
{
BufferSize = static_cast<size_t>(buffersize);
}
if (!fileOwner.empty() && BufferSize > 0)
{
errno = 0;
passwd passwordStruct{};
passwd *passwordResult = nullptr;
char buffer[kBufferSize];
int result = getpwnam_r(fileOwner.c_str(), &passwordStruct, buffer, kBufferSize, &passwordResult);
std::vector<char> buffer(BufferSize);
int result = getpwnam_r(fileOwner.c_str(), &passwordStruct, buffer.data(), BufferSize, &passwordResult);
if (result == 0 && passwordResult)
{
ownerId = passwordResult->pw_uid;
Expand All @@ -55,14 +64,23 @@ uid_t getFileOwnerId(const std::string &fileOwner)
gid_t getFileGroupId(const std::string &fileGroup)
{
gid_t groupId = kNoGroupChange;
const size_t kBufferSize = sysconf(_SC_GETPW_R_SIZE_MAX);
if (!fileGroup.empty() && kBufferSize > 0)
long buffersize = sysconf(_SC_GETPW_R_SIZE_MAX);
size_t BufferSize = 0;
if (buffersize == -1)
{
RIALTO_COMMON_LOG_SYS_WARN(errno, "Invalid Buffer Size '%s'", fileGroup.c_str());
}
if (buffersize > 0)
{
BufferSize = static_cast<size_t>(buffersize);
}
if (!fileGroup.empty() && BufferSize > 0)
{
errno = 0;
group groupStruct{};
group *groupResult = nullptr;
char buffer[kBufferSize];
int result = getgrnam_r(fileGroup.c_str(), &groupStruct, buffer, kBufferSize, &groupResult);
std::vector<char> buffer(BufferSize);
int result = getgrnam_r(fileGroup.c_str(), &groupStruct, buffer.data(), BufferSize, &groupResult);
if (result == 0 && groupResult)
{
groupId = groupResult->gr_gid;
Expand Down
34 changes: 26 additions & 8 deletions ipc/common/source/NamedSocket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -268,14 +268,23 @@ bool NamedSocket::getSocketLock()
uid_t NamedSocket::getSocketOwnerId(const std::string &socketOwner) const
{
uid_t ownerId = kNoOwnerChange;
const size_t kBufferSize = sysconf(_SC_GETPW_R_SIZE_MAX);
if (!socketOwner.empty() && kBufferSize > 0)
long buffersize = sysconf(_SC_GETPW_R_SIZE_MAX);
size_t BufferSize = 0;
if (buffersize == -1)
{
RIALTO_IPC_LOG_SYS_WARN(errno, "Invalid Buffer Size '%s'", socketOwner.c_str());
}
if (buffersize > 0)
{
BufferSize = static_cast<size_t>(buffersize);
}
if (!socketOwner.empty() && BufferSize > 0)
{
errno = 0;
passwd passwordStruct{};
passwd *passwordResult = nullptr;
char buffer[kBufferSize];
int result = getpwnam_r(socketOwner.c_str(), &passwordStruct, buffer, kBufferSize, &passwordResult);
std::vector<char> buffer(BufferSize);
int result = getpwnam_r(socketOwner.c_str(), &passwordStruct, buffer.data(), BufferSize, &passwordResult);
if (result == 0 && passwordResult)
{
ownerId = passwordResult->pw_uid;
Expand All @@ -291,14 +300,23 @@ uid_t NamedSocket::getSocketOwnerId(const std::string &socketOwner) const
gid_t NamedSocket::getSocketGroupId(const std::string &socketGroup) const
{
gid_t groupId = kNoGroupChange;
const size_t kBufferSize = sysconf(_SC_GETPW_R_SIZE_MAX);
if (!socketGroup.empty() && kBufferSize > 0)
long buffersize = sysconf(_SC_GETPW_R_SIZE_MAX);
size_t BufferSize = 0;
if (buffersize == -1)
{
RIALTO_IPC_LOG_SYS_WARN(errno, "Invalid Buffer Size '%s'", socketGroup.c_str());
}
if (buffersize > 0)
{
BufferSize = static_cast<size_t>(buffersize);
}
if (!socketGroup.empty() && BufferSize > 0)
{
errno = 0;
group groupStruct{};
group *groupResult = nullptr;
char buffer[kBufferSize];
int result = getgrnam_r(socketGroup.c_str(), &groupStruct, buffer, kBufferSize, &groupResult);
std::vector<char> buffer(BufferSize);
int result = getgrnam_r(socketGroup.c_str(), &groupStruct, buffer.data(), BufferSize, &groupResult);
if (result == 0 && groupResult)
{
groupId = groupResult->gr_gid;
Expand Down
2 changes: 1 addition & 1 deletion media/client/main/source/MediaPipeline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ MediaPipeline::MediaPipeline(std::weak_ptr<IMediaPipelineClient> client, const V
const std::shared_ptr<common::IMediaFrameWriterFactory> &mediaFrameWriterFactory,
IClientController &clientController)
: m_mediaPipelineClient(client), m_clientController{clientController}, m_currentAppState{ApplicationState::UNKNOWN},
m_mediaFrameWriterFactory(mediaFrameWriterFactory), m_currentState(State::IDLE)
m_mediaFrameWriterFactory(mediaFrameWriterFactory), m_currentState(State::IDLE), m_attachingSource(false)
{
RIALTO_CLIENT_LOG_DEBUG("entry:");

Expand Down
8 changes: 4 additions & 4 deletions media/public/include/IMediaPipeline.h
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,7 @@ class IMediaPipeline
*
* @retval the media key session id.
*/
const int32_t getMediaKeySessionId() const { return m_mediaKeySessionId; }
int32_t getMediaKeySessionId() const { return m_mediaKeySessionId; }

/**
* @brief Returns the key id. Empty if unencrypted.
Expand Down Expand Up @@ -571,14 +571,14 @@ class IMediaPipeline
*
* @retval the initWithLast15 value.
*/
const uint32_t getInitWithLast15() const { return m_initWithLast15; }
uint32_t getInitWithLast15() const { return m_initWithLast15; }

/**
* @brief Returns the segment alignment
*
* @retval the segment alignment
*/
const SegmentAlignment getSegmentAlignment() const { return m_alignment; }
SegmentAlignment getSegmentAlignment() const { return m_alignment; }

/**
* @brief Gets the codec data
Expand All @@ -602,7 +602,7 @@ class IMediaPipeline
*
* @retval if the encryption pattern has been set
*/
const bool getEncryptionPattern(uint32_t &crypt, uint32_t &skip) const
bool getEncryptionPattern(uint32_t &crypt, uint32_t &skip) const
{
crypt = m_crypt;
skip = m_skip;
Expand Down
2 changes: 1 addition & 1 deletion media/server/gstplayer/source/GstDecryptor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ GstRialtoDecryptorPrivate::GstRialtoDecryptorPrivate(
GstBaseTransform *parentElement,
const std::shared_ptr<firebolt::rialto::wrappers::IGstWrapperFactory> &gstWrapperFactory,
const std::shared_ptr<firebolt::rialto::wrappers::IGlibWrapperFactory> &glibWrapperFactory)
: m_decryptorElement(parentElement)
: m_decryptorElement(parentElement), m_decryptionService(nullptr)
{
if ((!gstWrapperFactory) || (!(m_gstWrapper = gstWrapperFactory->getGstWrapper())))
{
Expand Down
8 changes: 6 additions & 2 deletions media/server/gstplayer/source/GstGenericPlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1546,8 +1546,12 @@ bool GstGenericPlayer::setRenderFrame()
RIALTO_SERVER_LOG_INFO("Rendering preroll");

m_glibWrapper->gObjectSet(sink, kStepOnPrerollPropertyName.c_str(), 1, nullptr);
m_gstWrapper->gstElementSendEvent(sink, m_gstWrapper->gstEventNewStep(GST_FORMAT_BUFFERS, 1, 1.0, true,
false));
if (!m_gstWrapper->gstElementSendEvent(sink, m_gstWrapper->gstEventNewStep(GST_FORMAT_BUFFERS, 1, 1.0, true,
false)))
{
RIALTO_SERVER_LOG_ERROR("Failed to send new step event to sink element");
}

m_glibWrapper->gObjectSet(sink, kStepOnPrerollPropertyName.c_str(), 0, nullptr);
result = true;
}
Expand Down
2 changes: 2 additions & 0 deletions media/server/gstplayer/source/GstSrc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ static void gstRialtoSrcFinalize(GObject *object)
{
GstRialtoSrc *src = GST_RIALTO_SRC(object);
GstRialtoSrcPrivate *priv = src->priv;
GST_OBJECT_LOCK(src);
g_free(priv->uri);
GST_OBJECT_UNLOCK(src);
priv->~GstRialtoSrcPrivate();
GST_CALL_PARENT(G_OBJECT_CLASS, finalize, (object));
}
Expand Down
6 changes: 3 additions & 3 deletions media/server/ipc/source/MediaPipelineModuleService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -424,10 +424,10 @@ void MediaPipelineModuleService::attachSource(::google::protobuf::RpcController
std::shared_ptr<CodecData> codecData{};
if (request->has_codec_data())
{
auto codecDataProto = request->codec_data();
const auto &kCodecDataProto = request->codec_data();
codecData = std::make_shared<CodecData>();
codecData->data = std::vector<std::uint8_t>(codecDataProto.data().begin(), codecDataProto.data().end());
codecData->type = convertCodecDataType(codecDataProto.type());
codecData->data = std::vector<std::uint8_t>(kCodecDataProto.data().begin(), kCodecDataProto.data().end());
codecData->type = convertCodecDataType(kCodecDataProto.type());
}
std::unique_ptr<IMediaPipeline::MediaSource> mediaSource;
firebolt::rialto::SourceConfigType configType = convertConfigType(request->config_type());
Expand Down
1 change: 0 additions & 1 deletion media/server/main/interface/IMainThread.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
#ifndef FIREBOLT_RIALTO_SERVER_I_MAIN_THREAD_H_
#define FIREBOLT_RIALTO_SERVER_I_MAIN_THREAD_H_

#include "IMainThread.h"
#include <functional>
#include <memory>
#include <utility>
Expand Down
2 changes: 2 additions & 0 deletions media/server/main/source/ActiveRequests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ AddSegmentStatus ActiveRequests::addSegment(std::uint32_t requestId,
return AddSegmentStatus::ERROR;
}

std::unique_lock<std::mutex> lock{m_mutex};
auto requestIter{m_requestMap.find(requestId)};
if (requestIter != m_requestMap.end())
{
Expand All @@ -115,6 +116,7 @@ AddSegmentStatus ActiveRequests::addSegment(std::uint32_t requestId,

const IMediaPipeline::MediaSegmentVector &ActiveRequests::getSegments(std::uint32_t requestId) const
{
std::unique_lock<std::mutex> lock{m_mutex};
auto requestIter{m_requestMap.find(requestId)};
if (requestIter != m_requestMap.end())
{
Expand Down
2 changes: 1 addition & 1 deletion media/server/main/source/NeedMediaData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ NeedMediaData::NeedMediaData(std::weak_ptr<IMediaPipelineClient> client, IActive
const ISharedMemoryBuffer &shmBuffer, int sessionId, MediaSourceType mediaSourceType,
std::int32_t sourceId, PlaybackState currentPlaybackState)
: m_client{client}, m_activeRequests{activeRequests}, m_mediaSourceType{mediaSourceType}, m_frameCount{kMaxFrames},
m_sourceId{sourceId}
m_sourceId{sourceId}, m_maxMediaBytes{0}
{
if (MediaSourceType::AUDIO != mediaSourceType && MediaSourceType::VIDEO != mediaSourceType &&
MediaSourceType::SUBTITLE != mediaSourceType)
Expand Down
4 changes: 2 additions & 2 deletions serverManager/common/source/SessionServerAppManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@ bool SessionServerAppManager::configureSessionServerWithSocketName(const std::un
const auto kSocketPermissions{kSessionServer->getSessionManagementSocketPermissions()};
const auto kSocketOwner{kSessionServer->getSessionManagementSocketOwner()};
const auto kSocketGroup{kSessionServer->getSessionManagementSocketGroup()};
const auto kAppName{kSessionServer->getAppName()};
const auto &kAppName{kSessionServer->getAppName()};

const firebolt::rialto::common::MaxResourceCapabilitites kMaxResource{kSessionServer->getMaxPlaybackSessions(),
kSessionServer->getMaxWebAudioPlayers()};
Expand All @@ -508,7 +508,7 @@ bool SessionServerAppManager::configureSessionServerWithSocketFd(const std::uniq
const auto kInitialState{kSessionServer->getInitialState()};
const auto kSocketFd{kSessionServer->getSessionManagementSocketFd()};
const auto kClientDisplayName{kSessionServer->getClientDisplayName()};
const auto kAppName{kSessionServer->getAppName()};
const auto &kAppName{kSessionServer->getAppName()};

const firebolt::rialto::common::MaxResourceCapabilitites kMaxResource{kSessionServer->getMaxPlaybackSessions(),
kSessionServer->getMaxWebAudioPlayers()};
Expand Down
2 changes: 1 addition & 1 deletion wrappers/source/OcdmSession.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ const char *convertInitDataType(const firebolt::rialto::InitDataType &initDataTy
}
}
}
const firebolt::rialto::KeyStatus convertKeyStatus(const KeyStatus &ocdmKeyStatus)
firebolt::rialto::KeyStatus convertKeyStatus(const KeyStatus &ocdmKeyStatus)
{
switch (ocdmKeyStatus)
{
Expand Down
Loading