44#include < cassert>
55#include < cstring>
66
7+ using namespace firebolt ::rialto;
8+
79GstMediaPipeline::GstMediaPipeline ()
810{
911 std::cout << " Constructing GstMediaPipeline (Rialto-managed, public API)\n " ;
@@ -19,96 +21,58 @@ GstMediaPipeline::~GstMediaPipeline()
1921
2022bool GstMediaPipeline::init ()
2123{
22- std::shared_ptr<IMediaPipelineFactory> factory = IMediaPipelineFactory::createFactory ();
23- if (!factory)
24- {
25- std::cerr << " [GstMediaPipeline] ERROR: Failed to create IMediaPipelineFactory.\n " ;
26- return false ;
27- }
28- VideoRequirements requirements = {1920 , 1080 };
24+ // FIX: Calling createFactory() on IMediaPipelineFactory class, as it's not a member of IMediaPipeline.
25+ std::shared_ptr<IMediaPipelineFactory> factory = IMediaPipelineFactory::createFactory ();
26+ if (!factory) return false ;
2927
28+ VideoRequirements requirements = {};
29+
3030 m_pipeline = factory->createMediaPipeline (weak_from_this (), requirements);
31-
32- if (!m_pipeline)
33- {
34- std::cerr << " [GstMediaPipeline] ERROR: Failed to create Remote MediaPipeline. Is Rialto Server running?\n " ;
35- return false ;
36- }
37-
38- std::cout << " [GstMediaPipeline] SUCCESS: Rialto IPC Pipeline created.\n " ;
39- return true ;
40- }
41-
42- bool GstMediaPipeline::attachSource (std::unique_ptr<MediaSource> &&source, int32_t &sourceId)
43- {
44- return m_pipeline ? m_pipeline->attachSource (std::move (source), sourceId) : false ;
45- }
46-
47- bool GstMediaPipeline::play ()
48- {
49- return m_pipeline ? m_pipeline->play () : false ;
50- }
51-
52- bool GstMediaPipeline::stop ()
53- {
54- return m_pipeline ? m_pipeline->stop () : false ;
55- }
56-
57- bool GstMediaPipeline::setVideoWindow (uint32_t x, uint32_t y, uint32_t width, uint32_t height)
58- {
59- std::cout << " [GstMediaPipeline] Forwarding setVideoWindow to Rialto Server: " << width << " x" << height << " \n " ;
60- return m_pipeline ? m_pipeline->setVideoWindow (x, y, width, height) : false ;
61- }
62-
63- bool GstMediaPipeline::removeSource (int32_t id)
64- {
65- return m_pipeline ? m_pipeline->removeSource (id) : false ;
66- }
67-
68- bool GstMediaPipeline::allSourcesAttached ()
69- {
70- return m_pipeline ? m_pipeline->allSourcesAttached () : false ;
71- }
72-
73- bool GstMediaPipeline::load (MediaType type, const std::string &mimeType, const std::string &url)
74- {
75- return m_pipeline ? m_pipeline->load (type, mimeType, url) : false ;
31+
32+ return m_pipeline != nullptr ;
7633}
7734
78- AddSegmentStatus GstMediaPipeline::addSegment ( uint32_t needDataRequestId, const std::unique_ptr<MediaSegment > &mediaSegment )
35+ bool GstMediaPipeline::attachSource ( const std::unique_ptr<MediaSource > &source )
7936{
80- return m_pipeline ? m_pipeline->addSegment (needDataRequestId, mediaSegment ) : AddSegmentStatus::ERROR ;
37+ return m_pipeline ? m_pipeline->attachSource (source ) : false ;
8138}
8239
83- void GstMediaPipeline::notifyPlaybackState (PlaybackState state)
84- {
85- std::cout << " [Rialto Callback] PlaybackState: " << (int )state << " \n " ;
86- }
87-
88- void GstMediaPipeline::notifyPlaybackError (int32_t sourceId, PlaybackError error)
40+ bool GstMediaPipeline::attachSource (std::unique_ptr<MediaSource> &&source, int32_t &sourceId)
8941{
90- std::cerr << " [Rialto Callback] ERROR on source " << sourceId << " : " << (int )error << " \n " ;
91- }
92-
93- void GstMediaPipeline::notifyPosition (int64_t position) {}
94- void GstMediaPipeline::notifyNetworkState (NetworkState state) {}
95- void GstMediaPipeline::notifyQos (int32_t sourceId, const QosInfo &qosInfo) {}
96- void GstMediaPipeline::notifyBufferUnderflow (int32_t sourceId) {}
97- void GstMediaPipeline::notifySourceFlushed (int32_t sourceId) {}
42+ if (!source)
43+ {
44+ sourceId = 0 ;
45+ return false ;
46+ }
47+
48+ bool ok = attachSource (source);
9849
99- void GstMediaPipeline::notifyNeedMediaData (int32_t sourceId, size_t frameCount,
100- uint32_t needDataRequestId,
101- const std::shared_ptr<MediaPlayerShmInfo> &mediaPlayerShmInfo)
102- {
50+ if (ok)
51+ {
52+ sourceId = source->getId ();
53+ }
54+ else
55+ {
56+ sourceId = 0 ;
57+ }
58+
59+ return ok;
10360}
10461
62+ bool GstMediaPipeline::play () { return m_pipeline ? m_pipeline->play () : false ; }
63+ bool GstMediaPipeline::stop () { return m_pipeline ? m_pipeline->stop () : false ; }
64+ bool GstMediaPipeline::removeSource (int32_t id) { return m_pipeline ? m_pipeline->removeSource (id) : false ; }
65+ bool GstMediaPipeline::allSourcesAttached () { return m_pipeline ? m_pipeline->allSourcesAttached () : false ; }
66+ bool GstMediaPipeline::load (MediaType type, const std::string &mimeType, const std::string &url) { return m_pipeline ? m_pipeline->load (type, mimeType, url) : false ; }
67+ AddSegmentStatus GstMediaPipeline::addSegment (uint32_t needDataRequestId, const std::unique_ptr<MediaSegment> &mediaSegment) { return m_pipeline ? m_pipeline->addSegment (needDataRequestId, mediaSegment) : AddSegmentStatus::ERROR; }
10568bool GstMediaPipeline::pause () { return m_pipeline ? m_pipeline->pause () : false ; }
10669bool GstMediaPipeline::setPlaybackRate (double rate) { return m_pipeline ? m_pipeline->setPlaybackRate (rate) : false ; }
10770bool GstMediaPipeline::setPosition (int64_t position) { return m_pipeline ? m_pipeline->setPosition (position) : false ; }
10871bool GstMediaPipeline::getPosition (int64_t &position) { return m_pipeline ? m_pipeline->getPosition (position) : false ; }
10972bool GstMediaPipeline::getStats (int32_t sourceId, uint64_t &renderedFrames, uint64_t &droppedFrames) { return m_pipeline ? m_pipeline->getStats (sourceId, renderedFrames, droppedFrames) : false ; }
11073bool GstMediaPipeline::setImmediateOutput (int32_t sourceId, bool immediateOutput) { return m_pipeline ? m_pipeline->setImmediateOutput (sourceId, immediateOutput) : false ; }
11174bool GstMediaPipeline::getImmediateOutput (int32_t sourceId, bool &immediateOutput) { return m_pipeline ? m_pipeline->getImmediateOutput (sourceId, immediateOutput) : false ; }
75+ bool GstMediaPipeline::setVideoWindow (uint32_t x, uint32_t y, uint32_t width, uint32_t height) { return m_pipeline ? m_pipeline->setVideoWindow (x, y, width, height) : false ; }
11276bool GstMediaPipeline::haveData (MediaSourceStatus status, uint32_t needDataRequestId) { return m_pipeline ? m_pipeline->haveData (status, needDataRequestId) : false ; }
11377bool GstMediaPipeline::renderFrame () { return m_pipeline ? m_pipeline->renderFrame () : false ; }
11478bool GstMediaPipeline::setVolume (double targetVolume, uint32_t volumeDuration, EaseType easeType) { return m_pipeline ? m_pipeline->setVolume (targetVolume, volumeDuration, easeType) : false ; }
@@ -131,4 +95,22 @@ bool GstMediaPipeline::switchSource(const std::unique_ptr<MediaSource> &source)
13195bool GstMediaPipeline::getVolume (double ¤tVolume) { return m_pipeline ? m_pipeline->getVolume (currentVolume) : false ; }
13296bool GstMediaPipeline::setMute (int32_t sourceId, bool mute) { return m_pipeline ? m_pipeline->setMute (sourceId, mute) : false ; }
13397bool GstMediaPipeline::getMute (int32_t sourceId, bool &mute) { return m_pipeline ? m_pipeline->getMute (sourceId, mute) : false ; }
134- bool GstMediaPipeline::setTextTrackIdentifier (const std::string &textTrackIdentifier) { return m_pipeline ? m_pipeline->setTextTrackIdentifier (textTrackIdentifier) : false ; }
98+ bool GstMediaPipeline::setTextTrackIdentifier (const std::string &textTrackIdentifier) { return m_pipeline ? m_pipeline->setTextTrackIdentifier (textTrackIdentifier) : false ; }
99+
100+ // --- IMediaPipelineClient stubs ---
101+
102+ void GstMediaPipeline::notifyPlaybackState (PlaybackState state) { }
103+ void GstMediaPipeline::notifyPlaybackError (int32_t sourceId, PlaybackError error) { }
104+ void GstMediaPipeline::notifyPosition (int64_t position) {}
105+ void GstMediaPipeline::notifyNetworkState (NetworkState state) {}
106+ void GstMediaPipeline::notifyQos (int32_t sourceId, const QosInfo &qosInfo) {}
107+ void GstMediaPipeline::notifyBufferUnderflow (int32_t sourceId) {}
108+ void GstMediaPipeline::notifySourceFlushed (int32_t sourceId) {}
109+ void GstMediaPipeline::notifyNeedMediaData (int32_t sourceId, size_t frameCount,
110+ uint32_t needDataRequestId,
111+ const std::shared_ptr<MediaPlayerShmInfo> &mediaPlayerShmInfo) {}
112+ void GstMediaPipeline::notifyDuration (int64_t duration) {}
113+ void GstMediaPipeline::notifyNativeSize (uint32_t width, uint32_t height, double aspect) {}
114+ void GstMediaPipeline::notifyVideoData (bool hasData) {}
115+ void GstMediaPipeline::notifyAudioData (bool hasData) {}
116+ void GstMediaPipeline::notifyCancelNeedMediaData (int32_t sourceId) {}
0 commit comments