Skip to content

Commit 39afc46

Browse files
committed
TEST - DO NOT MERGE
Signed-off-by: ryadav698 <[email protected]>
1 parent fd10360 commit 39afc46

File tree

3 files changed

+92
-91
lines changed

3 files changed

+92
-91
lines changed

test/gstTestHarness/rialto-api-test.cpp

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -59,23 +59,32 @@ void ConfigureAudio()
5959

6060
bool hasDrm = false;
6161
std::string mimeType;
62-
StreamFormat streamFormat = StreamFormat::AAC;
63-
SegmentAlignment alignment = SegmentAlignment::AU;
62+
StreamFormat streamFormat;
63+
AudioConfig audioConfig;
64+
audioConfig.numberOfChannels = trackAudio.audio.channel_count;
65+
audioConfig.sampleRate = trackAudio.audio.samplerate;
66+
67+
// StreamFormat streamFormat = StreamFormat::AAC;
68+
// SegmentAlignment alignment = SegmentAlignment::AU;
6469

6570
switch( trackAudio.codec_type )
66-
{
67-
case MultiChar_Constant("mp4a"):
68-
mimeType = "audio/mp4";
69-
streamFormat = StreamFormat::AAC;
70-
break;
71-
default:
72-
assert(0);
73-
break;
74-
}
71+
{
72+
case MultiChar_Constant("esds"):
73+
mimeType = "audio/mpeg";
74+
streamFormat = StreamFormat::RAW;
75+
break;
76+
case MultiChar_Constant("dec3"):
77+
mimeType = "audio/x-eac3";
78+
streamFormat = StreamFormat::UNDEFINED;
79+
break;
80+
default:
81+
assert(0);
82+
break;
83+
}
7584

76-
CodecData codecData;
77-
const char *codec_ptr = trackAudio.codec_data.c_str();
78-
codecData.data = std::vector<uint8_t>( codec_ptr, &codec_ptr[trackAudio.codec_data.size()] );
85+
// CodecData codecData;
86+
// const char *codec_ptr = trackAudio.codec_data.c_str();
87+
// codecData.data = std::vector<uint8_t>( codec_ptr, &codec_ptr[trackAudio.codec_data.size()] );
7988

8089
std::unique_ptr<IMediaPipeline::MediaSourceAudio> sourceAudio =
8190
std::make_unique<IMediaPipeline::MediaSourceAudio>(
@@ -142,7 +151,7 @@ void InjectAudio()
142151
LoadAndDemuxSegment(trackAudio, "audio/chunk-stream0-00001.m4s");
143152
std::cout << "loading rialtotest /tmp/data/bipbop-gen/audio/chunk-stream0-00001.m4s" << std::endl;
144153

145-
size_t segmentCount = trackAudio.getSegmentCount();
154+
size_t segmentCount = trackAudio.getNbSegments(); // Corrected function name
146155
printf("adding %zu audio frames\n", segmentCount);
147156

148157
for (size_t i = 0; i < segmentCount; ++i)
@@ -171,7 +180,7 @@ void InjectVideo()
171180
LoadAndDemuxSegment(trackVideo, "video/chunk-stream0-00001.m4s");
172181
std::cout << "loading rialtotest /tmp/data/bipbop-gen/video/chunk-stream0-00001.m4s" << std::endl;
173182

174-
size_t segmentCount = trackVideo.getSegmentCount();
183+
size_t segmentCount = trackVideo.getNbSegments(); // Corrected function name
175184
printf("adding %zu video frames\n", segmentCount);
176185

177186
for (size_t i = 0; i < segmentCount; ++i)

test/gstTestHarness/rialto-gst-pipeline.cpp

Lines changed: 55 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
#include <cassert>
55
#include <cstring>
66

7+
using namespace firebolt::rialto;
8+
79
GstMediaPipeline::GstMediaPipeline()
810
{
911
std::cout << "Constructing GstMediaPipeline (Rialto-managed, public API)\n";
@@ -19,96 +21,58 @@ GstMediaPipeline::~GstMediaPipeline()
1921

2022
bool 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; }
10568
bool GstMediaPipeline::pause() { return m_pipeline ? m_pipeline->pause() : false; }
10669
bool GstMediaPipeline::setPlaybackRate(double rate) { return m_pipeline ? m_pipeline->setPlaybackRate(rate) : false; }
10770
bool GstMediaPipeline::setPosition(int64_t position) { return m_pipeline ? m_pipeline->setPosition(position) : false; }
10871
bool GstMediaPipeline::getPosition(int64_t &position) { return m_pipeline ? m_pipeline->getPosition(position) : false; }
10972
bool GstMediaPipeline::getStats(int32_t sourceId, uint64_t &renderedFrames, uint64_t &droppedFrames) { return m_pipeline ? m_pipeline->getStats(sourceId, renderedFrames, droppedFrames) : false; }
11073
bool GstMediaPipeline::setImmediateOutput(int32_t sourceId, bool immediateOutput) { return m_pipeline ? m_pipeline->setImmediateOutput(sourceId, immediateOutput) : false; }
11174
bool 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; }
11276
bool GstMediaPipeline::haveData(MediaSourceStatus status, uint32_t needDataRequestId) { return m_pipeline ? m_pipeline->haveData(status, needDataRequestId) : false; }
11377
bool GstMediaPipeline::renderFrame() { return m_pipeline ? m_pipeline->renderFrame() : false; }
11478
bool 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)
13195
bool GstMediaPipeline::getVolume(double &currentVolume) { return m_pipeline ? m_pipeline->getVolume(currentVolume) : false; }
13296
bool GstMediaPipeline::setMute(int32_t sourceId, bool mute) { return m_pipeline ? m_pipeline->setMute(sourceId, mute) : false; }
13397
bool 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) {}

test/gstTestHarness/rialto-gst-pipeline.h

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ class GstMediaPipeline : public IMediaPipeline,
2323

2424
std::weak_ptr<IMediaPipelineClient> getClient() override { return weak_from_this(); }
2525

26+
// IMediaPipelineClient Implementation (All required pure virtuals)
2627
void notifyNetworkState(NetworkState state) override;
2728
void notifyPlaybackState(PlaybackState state) override;
2829
void notifyPosition(int64_t position) override;
@@ -33,9 +34,18 @@ class GstMediaPipeline : public IMediaPipeline,
3334
void notifyBufferUnderflow(int32_t sourceId) override;
3435
void notifyPlaybackError(int32_t sourceId, PlaybackError error) override;
3536
void notifySourceFlushed(int32_t sourceId) override;
37+
void notifyDuration(int64_t duration) override;
38+
void notifyNativeSize(uint32_t width, uint32_t height, double aspect = 1.0) override;
39+
void notifyVideoData(bool hasData) override;
40+
void notifyAudioData(bool hasData) override;
41+
void notifyCancelNeedMediaData(int32_t sourceId) override;
42+
43+
// IMediaPipeline Implementation
44+
45+
46+
bool attachSource(const std::unique_ptr<MediaSource> &source) override;
47+
bool attachSource(std::unique_ptr<MediaSource> &&source, int32_t &sourceId);
3648

37-
bool attachSource(std::unique_ptr<MediaSource> &&source, int32_t &sourceId) override;
38-
bool attachSource(const std::unique_ptr<MediaSource> &source) override { return false; }
3949
bool removeSource(int32_t id) override;
4050
bool allSourcesAttached() override;
4151
bool load(MediaType type, const std::string &mimeType, const std::string &url) override;

0 commit comments

Comments
 (0)