Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed h265 playback on amlogic #286

Merged
merged 3 commits into from
Mar 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions media/client/ipc/source/MediaPipelineIpc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1159,6 +1159,14 @@ MediaPipelineIpc::convertStreamFormat(const firebolt::rialto::StreamFormat &stre
{
return firebolt::rialto::AttachSourceRequest_StreamFormat_STREAM_FORMAT_BYTE_STREAM;
}
case firebolt::rialto::StreamFormat::HVC1:
{
return firebolt::rialto::AttachSourceRequest_StreamFormat_STREAM_FORMAT_HVC1;
}
case firebolt::rialto::StreamFormat::HEV1:
{
return firebolt::rialto::AttachSourceRequest_StreamFormat_STREAM_FORMAT_HEV1;
}
}
return firebolt::rialto::AttachSourceRequest_StreamFormat_STREAM_FORMAT_UNDEFINED;
}
Expand Down
4 changes: 3 additions & 1 deletion media/public/include/MediaCommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,9 @@ enum class StreamFormat
UNDEFINED,
RAW,
AVC,
BYTE_STREAM
BYTE_STREAM,
HVC1,
HEV1
};

/**
Expand Down
4 changes: 3 additions & 1 deletion media/server/gstplayer/source/tasks/generic/AttachSource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,9 @@ class MediaSourceCapsBuilder
static const std::unordered_map<firebolt::rialto::StreamFormat, std::string> formatMap =
{{firebolt::rialto::StreamFormat::RAW, "raw"},
{firebolt::rialto::StreamFormat::AVC, "avc"},
{firebolt::rialto::StreamFormat::BYTE_STREAM, "byte-stream"}};
{firebolt::rialto::StreamFormat::BYTE_STREAM, "byte-stream"},
{firebolt::rialto::StreamFormat::HVC1, "hvc1"},
{firebolt::rialto::StreamFormat::HEV1, "hev1"}};

auto formatMapIt = formatMap.find(m_attachedSource.getStreamFormat());
if (formatMapIt != formatMap.end())
Expand Down
8 changes: 8 additions & 0 deletions media/server/ipc/source/MediaPipelineModuleService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,14 @@ firebolt::rialto::StreamFormat convertStreamFormat(const firebolt::rialto::Attac
{
return firebolt::rialto::StreamFormat::BYTE_STREAM;
}
case firebolt::rialto::AttachSourceRequest_StreamFormat_STREAM_FORMAT_HVC1:
{
return firebolt::rialto::StreamFormat::HVC1;
}
case firebolt::rialto::AttachSourceRequest_StreamFormat_STREAM_FORMAT_HEV1:
{
return firebolt::rialto::StreamFormat::HEV1;
}
default:
return firebolt::rialto::StreamFormat::UNDEFINED;
}
Expand Down
2 changes: 2 additions & 0 deletions proto/mediapipelinemodule.proto
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@ message AttachSourceRequest {
STREAM_FORMAT_RAW = 1;
STREAM_FORMAT_AVC = 2;
STREAM_FORMAT_BYTE_STREAM = 3;
STREAM_FORMAT_HVC1 = 4;
STREAM_FORMAT_HEV1 = 5;
}

enum ConfigType {
Expand Down
8 changes: 8 additions & 0 deletions tests/common/protoUtils/MediaPipelineProtoUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,14 @@ convertStreamFormat(const firebolt::rialto::StreamFormat &streamFormat)
{
return firebolt::rialto::AttachSourceRequest_StreamFormat_STREAM_FORMAT_BYTE_STREAM;
}
case firebolt::rialto::StreamFormat::HVC1:
{
return firebolt::rialto::AttachSourceRequest_StreamFormat_STREAM_FORMAT_HVC1;
}
case firebolt::rialto::StreamFormat::HEV1:
{
return firebolt::rialto::AttachSourceRequest_StreamFormat_STREAM_FORMAT_HEV1;
}
}
return firebolt::rialto::AttachSourceRequest_StreamFormat_STREAM_FORMAT_UNDEFINED;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -731,12 +731,16 @@ void GenericTasksTestsBase::triggerAttachOpusAudioSourceWithAudioSpecificConf()
task.execute();
}

void GenericTasksTestsBase::shouldAttachVideoSource()
void GenericTasksTestsBase::shouldAttachVideoSource(const std::string &mime, const std::string &alignment,
const std::string &format)
{
gpointer memory = nullptr;
expectSetGenericVideoCaps();
EXPECT_CALL(*testContext->m_gstWrapper, gstCapsNewEmptySimple(StrEq("video/x-h264")))
.WillOnce(Return(&testContext->m_gstCaps1));
EXPECT_CALL(*testContext->m_gstWrapper,
gstCapsSetSimpleStringStub(&testContext->m_gstCaps1, StrEq("alignment"), _, StrEq(alignment)));
EXPECT_CALL(*testContext->m_gstWrapper,
gstCapsSetSimpleStringStub(&testContext->m_gstCaps1, StrEq("stream-format"), _, StrEq(format)));
EXPECT_CALL(*testContext->m_gstWrapper, gstCapsNewEmptySimple(StrEq(mime))).WillOnce(Return(&testContext->m_gstCaps1));
EXPECT_CALL(*testContext->m_glibWrapper, gMemdup(arrayMatcher(kCodecDataBuffer->data), kCodecDataBuffer->data.size()))
.WillOnce(Return(memory));
EXPECT_CALL(*testContext->m_gstWrapper, gstBufferNewWrapped(memory, kCodecDataBuffer->data.size()))
Expand All @@ -746,12 +750,13 @@ void GenericTasksTestsBase::shouldAttachVideoSource()
EXPECT_CALL(*testContext->m_gstWrapper, gstBufferUnref(&(testContext->m_videoBuffer)));
}

void GenericTasksTestsBase::triggerAttachVideoSource()
void GenericTasksTestsBase::triggerAttachVideoSource(const std::string &mimeType,
firebolt::rialto::SegmentAlignment segmentAligment,
firebolt::rialto::StreamFormat streamFormat)
{
std::unique_ptr<firebolt::rialto::IMediaPipeline::MediaSource> source =
std::make_unique<firebolt::rialto::IMediaPipeline::MediaSourceVideo>("video/h264", false, kWidth, kHeight,
firebolt::rialto::SegmentAlignment::AU,
firebolt::rialto::StreamFormat::AVC,
std::make_unique<firebolt::rialto::IMediaPipeline::MediaSourceVideo>(mimeType, false, kWidth, kHeight,
segmentAligment, streamFormat,
kCodecDataBuffer);
firebolt::rialto::server::tasks::generic::AttachSource task{testContext->m_context,
testContext->m_gstWrapper,
Expand Down Expand Up @@ -794,6 +799,10 @@ void GenericTasksTestsBase::checkSubtitleSourceAttached()
void GenericTasksTestsBase::shouldAttachVideoSourceWithStringCodecData()
{
expectSetGenericVideoCaps();
EXPECT_CALL(*testContext->m_gstWrapper,
gstCapsSetSimpleStringStub(&testContext->m_gstCaps1, StrEq("alignment"), _, StrEq("au")));
EXPECT_CALL(*testContext->m_gstWrapper,
gstCapsSetSimpleStringStub(&testContext->m_gstCaps1, StrEq("stream-format"), _, StrEq("avc")));
EXPECT_CALL(*testContext->m_gstWrapper, gstCapsNewEmptySimple(StrEq("video/x-h264")))
.WillOnce(Return(&testContext->m_gstCaps1));
EXPECT_CALL(*testContext->m_gstWrapper, gstCapsSetSimpleStringStub(&testContext->m_gstCaps1, StrEq("codec_data"),
Expand Down Expand Up @@ -873,6 +882,10 @@ void GenericTasksTestsBase::shouldAttachVideoSourceWithDolbyVisionSource()
{
gpointer memory = nullptr;
expectSetGenericVideoCaps();
EXPECT_CALL(*testContext->m_gstWrapper,
gstCapsSetSimpleStringStub(&testContext->m_gstCaps1, StrEq("alignment"), _, StrEq("au")));
EXPECT_CALL(*testContext->m_gstWrapper,
gstCapsSetSimpleStringStub(&testContext->m_gstCaps1, StrEq("stream-format"), _, StrEq("avc")));
EXPECT_CALL(*testContext->m_gstWrapper, gstCapsNewEmptySimple(StrEq("video/x-h265")))
.WillOnce(Return(&testContext->m_gstCaps1));
EXPECT_CALL(*testContext->m_glibWrapper, gMemdup(arrayMatcher(kCodecDataBuffer->data), kCodecDataBuffer->data.size()))
Expand Down Expand Up @@ -910,10 +923,6 @@ void GenericTasksTestsBase::expectSetGenericVideoCaps()
gstCapsSetSimpleIntStub(&testContext->m_gstCaps1, StrEq("width"), G_TYPE_INT, kWidth));
EXPECT_CALL(*testContext->m_gstWrapper,
gstCapsSetSimpleIntStub(&testContext->m_gstCaps1, StrEq("height"), G_TYPE_INT, kHeight));
EXPECT_CALL(*testContext->m_gstWrapper,
gstCapsSetSimpleStringStub(&testContext->m_gstCaps1, StrEq("alignment"), _, StrEq("au")));
EXPECT_CALL(*testContext->m_gstWrapper,
gstCapsSetSimpleStringStub(&testContext->m_gstCaps1, StrEq("stream-format"), _, StrEq("avc")));
EXPECT_CALL(*testContext->m_gstWrapper, gstCapsToString(&testContext->m_gstCaps1))
.WillOnce(Return(&testContext->m_capsStr));
EXPECT_CALL(*testContext->m_glibWrapper, gFree(&testContext->m_capsStr));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#define GENERIC_TASKS_TESTS_BASE_H_

#include "MediaCommon.h"
#include <string>

#include <gmock/gmock.h>
#include <gtest/gtest.h>
Expand Down Expand Up @@ -124,8 +125,9 @@ class GenericTasksTestsBase : public ::testing::Test
void checkAudioSourceAttachedWithDrm();
void shouldAttachAudioSourceWithAudioSpecificConf();
void triggerAttachOpusAudioSourceWithAudioSpecificConf();
void shouldAttachVideoSource();
void triggerAttachVideoSource();
void shouldAttachVideoSource(const std::string &mime, const std::string &alignment, const std::string &format);
void triggerAttachVideoSource(const std::string &mimeType, firebolt::rialto::SegmentAlignment segmentAligment,
firebolt::rialto::StreamFormat streamFormat);
void checkVideoSourceAttached();
void checkSubtitleSourceAttached();
void triggerAttachSubtitleSource();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,59 @@ TEST_F(AttachSourceTest, shouldAttachOpusWithAudioSpecificConf)
checkAudioSourceAttached();
}

TEST_F(AttachSourceTest, shouldAttachVideoSource)
TEST_F(AttachSourceTest, shouldAttachVideoSourceAuAvc)
{
shouldAttachVideoSource();
triggerAttachVideoSource();
std::string mimeType = "video/h264";
firebolt::rialto::SegmentAlignment alignment = firebolt::rialto::SegmentAlignment::AU;
firebolt::rialto::StreamFormat streamFormat = firebolt::rialto::StreamFormat::AVC;
std::string expectedMimeType = "video/x-h264";
std::string expectedAlignment = "au";
std::string expectedStreamFormat = "avc";

shouldAttachVideoSource(expectedMimeType, expectedAlignment, expectedStreamFormat);
triggerAttachVideoSource(mimeType, alignment, streamFormat);
checkVideoSourceAttached();
}

TEST_F(AttachSourceTest, shouldAttachVideoSourceNalAvc)
{
std::string mimeType = "video/h264";
firebolt::rialto::SegmentAlignment alignment = firebolt::rialto::SegmentAlignment::NAL;
firebolt::rialto::StreamFormat streamFormat = firebolt::rialto::StreamFormat::AVC;
std::string expectedMimeType = "video/x-h264";
std::string expectedAlignment = "nal";
std::string expectedStreamFormat = "avc";

shouldAttachVideoSource(expectedMimeType, expectedAlignment, expectedStreamFormat);
triggerAttachVideoSource(mimeType, alignment, streamFormat);
checkVideoSourceAttached();
}

TEST_F(AttachSourceTest, shouldAttachVideoSourceAuHvc)
{
std::string mimeType = "video/h265";
firebolt::rialto::SegmentAlignment alignment = firebolt::rialto::SegmentAlignment::AU;
firebolt::rialto::StreamFormat streamFormat = firebolt::rialto::StreamFormat::HVC1;
std::string expectedMimeType = "video/x-h265";
std::string expectedAlignment = "au";
std::string expectedStreamFormat = "hvc1";

shouldAttachVideoSource(expectedMimeType, expectedAlignment, expectedStreamFormat);
triggerAttachVideoSource(mimeType, alignment, streamFormat);
checkVideoSourceAttached();
}

TEST_F(AttachSourceTest, shouldAttachVideoSourceAuHev)
{
std::string mimeType = "video/h265";
firebolt::rialto::SegmentAlignment alignment = firebolt::rialto::SegmentAlignment::AU;
firebolt::rialto::StreamFormat streamFormat = firebolt::rialto::StreamFormat::HEV1;
std::string expectedMimeType = "video/x-h265";
std::string expectedAlignment = "au";
std::string expectedStreamFormat = "hev1";

shouldAttachVideoSource(expectedMimeType, expectedAlignment, expectedStreamFormat);
triggerAttachVideoSource(mimeType, alignment, streamFormat);
checkVideoSourceAttached();
}

Expand Down
Loading