Skip to content

Commit

Permalink
Merge branch 'release/xumo_2' into release/xumo_2
Browse files Browse the repository at this point in the history
  • Loading branch information
adrianM27 authored May 13, 2024
2 parents e277a57 + 9fea6f4 commit 801d6ad
Show file tree
Hide file tree
Showing 17 changed files with 596 additions and 1,180 deletions.
15 changes: 15 additions & 0 deletions Miracast/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,21 @@ All notable changes to this RDK Service will be documented in this file.
Changes in CHANGELOG should be updated when commits are added to the main or release branches. There should be one CHANGELOG entry per JIRA Ticket. This is not enforced on sprint branches since there could be multiple changes for the same JIRA ticket during development.

For more details, refer to versioning section under Main README.
## [1.0.6] - 2024-05-02
### Fixed
- Removed the stale P2P Group interface during the plugin activation.
- Added the MiracastService changes to handle the Direct P2P Group Started events
- Fixed the SIGBUS/SIGSEV crash in Apache4K while do playRequest with MiracastPlayer plugin

## [1.0.5] - 2024-04-04
### Fixed
- Added the synchronization for enable/disable the MiracastService discovery.
- Added the check to avoid the P2P events when MiracastService discovery not enabled.

## [1.0.4] - 2024-03-06
### Fixed
- Added the timer to get and update the friendlyName for Miracast if it fails get it from SystemServices.

## [1.0.3] - 2023-12-22
### Added
- Added the opt flags to suppress P2P events and change config methods and dynamically handled the authType.
Expand Down
112 changes: 35 additions & 77 deletions Miracast/MiracastPlayer/MiracastGstPlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,37 +79,6 @@ MiracastGstPlayer::~MiracastGstPlayer()
MIRACASTLOG_TRACE("Exiting...");
}

bool MiracastGstPlayer::setUri(const std::string ipaddr, const std::string port)
{
if (ipaddr.empty())
{
MIRACASTLOG_ERROR("Empty ipaddress");
return false;
}
if (port.empty())
{
MIRACASTLOG_ERROR("Empty port");
return false;
}

m_uri = "udp://" + ipaddr + ":" + port;
return true;
}

std::string MiracastGstPlayer::getUri()
{
return m_uri;
}

unsigned getGstPlayFlag(const char *nick)
{
MIRACASTLOG_TRACE("Entering..!!!");
static GFlagsClass *flagsClass = static_cast<GFlagsClass *>(g_type_class_ref(g_type_from_name("GstPlayFlags")));
GFlagsValue *flag = g_flags_get_value_by_nick(flagsClass, nick);
MIRACASTLOG_TRACE("Exiting..!!!");
return (flag ? flag->value : 0);
}

bool MiracastGstPlayer::setVideoRectangle( VIDEO_RECT_STRUCT video_rect , bool apply )
{
bool ret = false;
Expand Down Expand Up @@ -146,29 +115,31 @@ bool MiracastGstPlayer::updateVideoSinkRectangle(void)
m_video_rect_st.width, m_video_rect_st.height);
g_object_set(G_OBJECT(m_video_sink), "window-set", rectString, nullptr);
}

MIRACASTLOG_TRACE("Exiting...");

return ret;
}

bool MiracastGstPlayer::launch(std::string localip , std::string streaming_port, MiracastRTSPMsg *rtsp_instance)
bool MiracastGstPlayer::launch(std::string& localip , std::string& streaming_port, MiracastRTSPMsg *rtsp_instance)
{
char urlBuffer[128] = {0};
bool ret = false;

if (setUri(localip, streaming_port))
MIRACASTLOG_TRACE("Entering...");

snprintf(urlBuffer,sizeof(urlBuffer),"udp://%s:%s",localip.c_str(),streaming_port.c_str());
m_uri = urlBuffer;

m_streaming_port = std::stoull(streaming_port.c_str());
if ( nullptr != rtsp_instance )
{
m_streaming_port = std::stoull(streaming_port.c_str());
if ( nullptr != rtsp_instance )
{
m_rtsp_reference_instance = rtsp_instance;
}
ret = createPipeline();
if ( !ret ){
m_rtsp_reference_instance = nullptr;
MIRACASTLOG_ERROR("Failed to create the pipeline");
}
m_rtsp_reference_instance = rtsp_instance;
}
ret = createPipeline();
if ( !ret ){
m_rtsp_reference_instance = nullptr;
MIRACASTLOG_ERROR("Failed to create the pipeline");
}
MIRACASTLOG_TRACE("Exiting...");
return ret;
}

Expand All @@ -191,30 +162,31 @@ bool MiracastGstPlayer::stop()
MIRACASTLOG_ERROR("Pipeline is NULL");
return false;
}
m_statistics_thread_loop = false;
if (m_player_statistics_tid){
pthread_cancel(m_player_statistics_tid);
pthread_join(m_player_statistics_tid,nullptr);
m_player_statistics_tid = 0;
}

if (m_main_loop)
{
g_main_loop_quit(m_main_loop);
}
if (m_playback_thread)
{
pthread_cancel(m_playback_thread);
pthread_join(m_playback_thread,nullptr);
}

GstStateChangeReturn ret;
ret = gst_element_set_state(m_pipeline, GST_STATE_NULL);
if (ret == GST_STATE_CHANGE_FAILURE)
{
MIRACASTLOG_ERROR("Failed to set gst_element_set_state as NULL");
}

GstBus *bus = gst_pipeline_get_bus(GST_PIPELINE(m_pipeline));
if (bus)
{
gst_bus_set_sync_handler(bus, nullptr, nullptr, nullptr);
gst_object_unref(bus);
}

if (m_audio_sink)
{
gst_object_unref(m_audio_sink);
Expand Down Expand Up @@ -255,7 +227,6 @@ bool MiracastGstPlayer::stop()
gst_object_unref(m_vQueue);
m_vQueue = nullptr;
}

if (m_tsdemux)
{
gst_object_unref(m_tsdemux);
Expand All @@ -266,7 +237,6 @@ bool MiracastGstPlayer::stop()
gst_object_unref(m_tsparse);
m_tsparse = nullptr;
}

if (m_rtpmp2tdepay)
{
gst_object_unref(m_rtpmp2tdepay);
Expand All @@ -282,7 +252,6 @@ bool MiracastGstPlayer::stop()
gst_object_unref(m_udpsrc);
m_udpsrc = nullptr;
}

if (m_main_loop)
{
g_main_loop_unref(m_main_loop);
Expand All @@ -293,7 +262,6 @@ bool MiracastGstPlayer::stop()
g_main_context_unref(m_main_loop_context);
m_main_loop_context = nullptr;
}

if (m_pipeline)
{
g_object_unref(m_pipeline);
Expand Down Expand Up @@ -347,10 +315,11 @@ void* MiracastGstPlayer::monitor_player_statistics_thread(void *ctx)
MiracastGstPlayer *self = (MiracastGstPlayer *)ctx;

int time_interval_sec = 60;
while (true)
self->m_statistics_thread_loop = true;
while (true == self->m_statistics_thread_loop)
{
isInteger = true;
time_interval_sec = 120;
time_interval_sec = 5;
std::ifstream player_stats_monitor_delay("/opt/miracast_player_stats"); // Assuming the input file is named "input.txt"

if (!player_stats_monitor_delay)
Expand Down Expand Up @@ -573,28 +542,17 @@ gboolean MiracastGstPlayer::busMessageCb(GstBus *bus, GstMessage *msg, gpointer

if (GST_MESSAGE_SRC(msg) == GST_OBJECT(self->m_pipeline))
{
char fileName[128] = {0};
static int id = 0;
id++;
#if 0
gst_message_parse_state_changed(msg, &old, &now, &pending);
if (memcmp(GST_OBJECT_NAME(GST_MESSAGE_SRC(msg)), "miracast_player", strlen("miracast_player")) == 0)
{
MIRACASTLOG_INFO("Element [%s], Pipeline state change from Old [%s] -> New [%s] and Pending state is [%s]",
GST_ELEMENT_NAME(GST_MESSAGE_SRC(msg)),
gst_element_state_get_name(old),
gst_element_state_get_name(now),
gst_element_state_get_name(pending));
}
#endif
std::string file_name = "miracast_player_";
file_name += (GST_OBJECT_NAME(self->m_pipeline));
file_name += "_" + std::to_string(id);
file_name += "_";
file_name += gst_element_state_get_name(old);
file_name += "_";
file_name += gst_element_state_get_name(now);

GST_DEBUG_BIN_TO_DOT_FILE((GstBin *)self->m_pipeline, GST_DEBUG_GRAPH_SHOW_ALL, file_name.c_str());
snprintf( fileName,
sizeof(fileName),
"MiracastPlayer_%s_%s_%s_%s_DBG",
GST_OBJECT_NAME(self->m_pipeline),
std::to_string(id).c_str(),
gst_element_state_get_name(old),
gst_element_state_get_name(now));
GST_DEBUG_BIN_TO_DOT_FILE((GstBin *)self->m_pipeline, GST_DEBUG_GRAPH_SHOW_ALL, fileName);
}
break;
}
Expand Down
7 changes: 3 additions & 4 deletions Miracast/MiracastPlayer/MiracastGstPlayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,17 @@ class MiracastGstPlayer
public:
static MiracastGstPlayer *getInstance();
static void destroyInstance();
bool launch(std::string localip , std::string streaming_port,MiracastRTSPMsg *rtsp_instance);
bool launch(std::string& localip , std::string& streaming_port,MiracastRTSPMsg *rtsp_instance);
bool stop();
bool pause();
bool resume();
bool setVideoRectangle( VIDEO_RECT_STRUCT video_rect , bool apply = false );
int getPlayerstate();
bool setUri(std::string ipaddr, std::string port);
std::string getUri();
double getDuration(GstElement *pipeline = nullptr);
bool seekTo(double seconds,GstElement *pipeline = nullptr);
double getCurrentPosition(GstElement *pipeline = nullptr);
bool get_player_statistics();
void print_pipeline_state(GstElement *pipeline = nullptr);
//static std::string parse_opt_flag( std::string file_name , bool integer_check = false );

private:
GstElement *m_pipeline{nullptr};
Expand Down Expand Up @@ -94,6 +91,8 @@ class MiracastGstPlayer
static void *playbackThread(void *ctx);
GMainLoop *m_main_loop{nullptr};
GMainContext *m_main_loop_context{nullptr};

bool m_statistics_thread_loop{false};

pthread_t m_player_statistics_tid;
static void *monitor_player_statistics_thread(void *ctx);
Expand Down
Loading

0 comments on commit 801d6ad

Please sign in to comment.