Files
firefox/dom/media/gtest/TestVideoSegment.cpp
T
Andreas Pehrson 87553a4818 Bug 1208371 - Add PrincipalHandle to MediaChunks. r=mt,jesup
PrincipalHandle is a thread safe pointer to a holder of (the main-thread-only
nsIPrincipal) that can be passed around the MSG.

A MediaStreamTrack whose source has just updated its principal, sets the new
principal aside (as its "pending principal"), and combines the new principal
into its current principal.

Then the source starts passing the new principal to the MediaStreamGraph as
a PrincipalHandle.

Changes to a track's PrincipalHandle on the MSG will be surfaced through the
MediaStreamTrackListener API. These changes are dispatched to main thread
and compared to a MediaStreamTrack's pending principal. In case of a match
the track knows the correct principal is flowing and can move the pending
principal to be the current principal and update any main thread principal
observers.

MozReview-Commit-ID: D0JXGWhQFFU
2016-04-06 14:56:44 +02:00

52 lines
1.4 KiB
C++

/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "gtest/gtest.h"
#include "VideoSegment.h"
using namespace mozilla;
namespace mozilla {
namespace layer {
class Image;
} // namespace layer
} // namespace mozilla
TEST(VideoSegment, TestAppendFrameForceBlack)
{
RefPtr<layers::Image> testImage = nullptr;
VideoSegment segment;
segment.AppendFrame(testImage.forget(),
mozilla::StreamTime(90000),
mozilla::gfx::IntSize(640, 480),
PRINCIPAL_HANDLE_NONE,
true);
VideoSegment::ChunkIterator iter(segment);
while (!iter.IsEnded()) {
VideoChunk chunk = *iter;
EXPECT_TRUE(chunk.mFrame.GetForceBlack());
iter.Next();
}
}
TEST(VideoSegment, TestAppendFrameNotForceBlack)
{
RefPtr<layers::Image> testImage = nullptr;
VideoSegment segment;
segment.AppendFrame(testImage.forget(),
mozilla::StreamTime(90000),
mozilla::gfx::IntSize(640, 480),
PRINCIPAL_HANDLE_NONE);
VideoSegment::ChunkIterator iter(segment);
while (!iter.IsEnded()) {
VideoChunk chunk = *iter;
EXPECT_FALSE(chunk.mFrame.GetForceBlack());
iter.Next();
}
}