Commit bda524f2 authored by Xiaohan Wang's avatar Xiaohan Wang Committed by Commit Bot

media: Remove `playback_element_id` in MediaFoundationRenderer

This ID is not needed since there's a strict 1:1 mapping between the
media player (Renderer) and CDM in Chromium.

Bug: 999747
Change-Id: I5cbe7346a29d2ef47be3c307e508db037c71b102
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2314668Reviewed-by: default avatarJohn Rummell <jrummell@chromium.org>
Commit-Queue: Xiaohan Wang <xhwang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#792340}
parent 18c4f763
......@@ -31,28 +31,20 @@ IMFCdmProxy : public IUnknown {
// |content_init_data| is optional initialization data as in
// https://www.w3.org/TR/encrypted-media/#initialization-data
virtual HRESULT STDMETHODCALLTYPE GetInputTrustAuthority(
_In_ uint64_t playback_element_id, _In_ uint32_t stream_id,
_In_ uint32_t stream_count,
_In_ uint32_t stream_id, _In_ uint32_t stream_count,
_In_reads_bytes_opt_(content_init_data_size)
const uint8_t* content_init_data,
_In_ uint32_t content_init_data_size, _In_ REFIID riid,
_COM_Outptr_ IUnknown** object_out) = 0;
// MediaFoundationSourceWrapper provides its last set of key ids
// associated with a playback element id using SetLastKeyIds when it is
// destructed.
// Another instance of MediaFoundationSourceWrapper could then invoke
// RefreshTrustedInput to let implementation to reuse those key ids
// information when it happens to have the same playback element id.
//
// |playback_element_id| is an ID corresponding to a particular instance of
// video playback element.
virtual HRESULT STDMETHODCALLTYPE RefreshTrustedInput(
_In_ uint64_t playback_element_id) = 0;
virtual HRESULT STDMETHODCALLTYPE SetLastKeyIds(
_In_ uint64_t playback_element_id, GUID * key_ids,
// When the media Renderer is suspended, `MediaFoundationSourceWrapper`
// provides its last set of key IDs using `SetLastKeyIds()` when it is
// destructed. Then during resume, the new `MediaFoundationSourceWrapper`
// calls `RefreshTrustedInput()` to let the CDM use the key ID information to
// perform some optimization.
virtual HRESULT STDMETHODCALLTYPE SetLastKeyIds(GUID * key_ids,
uint32_t key_ids_count) = 0;
virtual HRESULT STDMETHODCALLTYPE RefreshTrustedInput() = 0;
// Used by MediaFoundationProtectionManager to implement
// IMFContentProtectionManager::BeginEnableContent as in
......
......@@ -44,8 +44,7 @@ class CdmProxyImpl
return S_OK;
}
STDMETHODIMP GetInputTrustAuthority(uint64_t playback_element_id,
uint32_t stream_id,
STDMETHODIMP GetInputTrustAuthority(uint32_t stream_id,
uint32_t /*stream_count*/,
const uint8_t* content_init_data,
uint32_t content_init_data_size,
......@@ -79,15 +78,13 @@ class CdmProxyImpl
}
// TODO(xhwang): Implement this.
STDMETHODIMP RefreshTrustedInput(uint64_t playback_element_id) override {
STDMETHODIMP SetLastKeyIds(GUID* key_ids, uint32_t key_ids_count) override {
NOTIMPLEMENTED();
return S_OK;
}
// TODO(xhwang): Implement this.
STDMETHODIMP SetLastKeyIds(uint64_t playback_element_id,
GUID* key_ids,
uint32_t key_ids_count) override {
STDMETHODIMP RefreshTrustedInput() override {
NOTIMPLEMENTED();
return S_OK;
}
......
......@@ -192,13 +192,8 @@ HRESULT MediaFoundationRenderer::CreateMediaEngine(
return E_INVALIDARG;
}
if (!playback_element_id_) {
DLOG(ERROR) << "Invalid playback_element_id_.";
return HRESULT_FROM_WIN32(ERROR_INVALID_STATE);
}
RETURN_IF_FAILED(MakeAndInitialize<MediaFoundationSourceWrapper>(
&mf_source_, playback_element_id_, media_resource, task_runner_));
&mf_source_, media_resource, task_runner_));
if (force_dcomp_mode_for_testing_)
SetDCompMode(true, base::DoNothing());
......@@ -445,13 +440,6 @@ void MediaFoundationRenderer::SetVideoStreamEnabled(bool enabled) {
}
}
void MediaFoundationRenderer::SetPlaybackElementId(
uint64_t playback_element_id) {
DVLOG_FUNC(1) << "playback_element_id=" << playback_element_id;
playback_element_id_ = playback_element_id;
}
void MediaFoundationRenderer::SetOutputParams(const gfx::Rect& output_rect) {
DVLOG_FUNC(2);
......
......@@ -66,9 +66,6 @@ class MEDIA_EXPORT MediaFoundationRenderer
void SetDCompMode(bool enabled, SetDCompModeCB callback) override;
void GetDCompSurface(GetDCompSurfaceCB callback) override;
void SetVideoStreamEnabled(bool enabled) override;
// SetPlaybackElementId() must be called before Initialize() as
// |playback_element_id| is used in Initialize().
void SetPlaybackElementId(uint64_t playback_element_id) override;
void SetOutputParams(const gfx::Rect& output_rect) override;
private:
......@@ -137,12 +134,6 @@ class MEDIA_EXPORT MediaFoundationRenderer
PipelineStatistics statistics_ = {};
base::RepeatingTimer statistics_timer_;
// An identifier corresponds to a WebMediaPlayer. It allows MFMediaEngine
// to track the same playback session is running as Renderer can be destroyed
// after a period of inactivity by Chromium media pipeliine.
// Init it to an invalid ID.
uint64_t playback_element_id_ = 0;
// A fake window handle passed to MF-based rendering pipeline for OPM.
HWND virtual_video_window_ = nullptr;
......
......@@ -33,9 +33,6 @@ class MEDIA_EXPORT MediaFoundationRendererExtension {
// Notify renderer whether video is enabled.
virtual void SetVideoStreamEnabled(bool enabled) = 0;
// Provide a unique identifier which maps to a specific playback element.
virtual void SetPlaybackElementId(uint64_t playback_element_id) = 0;
// Notify renderer of output composition parameters.
virtual void SetOutputParams(const ::gfx::Rect& rect) = 0;
};
......
......@@ -28,10 +28,6 @@ std::unique_ptr<Renderer> MediaFoundationRendererFactory::CreateRenderer(
/*muted=*/false, media_task_runner,
/*force_dcomp_mode_for_testing=*/true);
auto playback_element_id = next_playback_element_id_++;
CHECK(playback_element_id);
renderer->SetPlaybackElementId(playback_element_id);
return renderer;
}
......
......@@ -30,10 +30,6 @@ class MEDIA_EXPORT MediaFoundationRendererFactory : public RendererFactory {
VideoRendererSink* video_renderer_sink,
RequestOverlayInfoCB request_overlay_info_cb,
const gfx::ColorSpace& target_color_space) final;
private:
// Zero is treated as invalid playback element ID by MediaFoundationRenderer.
uint64_t next_playback_element_id_ = 1;
};
} // namespace media
......
......@@ -65,7 +65,6 @@ class MediaFoundationRendererIntegrationTest
auto renderer = std::make_unique<MediaFoundationRenderer>(
/*muted=*/false, task_environment_.GetMainThreadTaskRunner(),
/*force_dcomp_mode_for_testing=*/true);
renderer->SetPlaybackElementId(1); // Must be set before Initialize().
return renderer;
}
......
......@@ -40,20 +40,16 @@ class MockMFCdmProxy
// IMFCdmProxy.
MOCK_STDCALL_METHOD2(GetPMPServer,
HRESULT(REFIID riid, void** object_result));
MOCK_STDCALL_METHOD7(GetInputTrustAuthority,
HRESULT(uint64_t playback_element_id,
uint32_t stream_id,
MOCK_STDCALL_METHOD6(GetInputTrustAuthority,
HRESULT(uint32_t stream_id,
uint32_t stream_count,
const uint8_t* content_init_data,
uint32_t content_init_data_size,
REFIID riid,
IUnknown** object_result));
MOCK_STDCALL_METHOD1(RefreshTrustedInput,
HRESULT(uint64_t playback_element_id));
MOCK_STDCALL_METHOD3(SetLastKeyIds,
HRESULT(uint64_t playback_element_id,
GUID* key_ids,
uint32_t key_ids_count));
MOCK_STDCALL_METHOD2(SetLastKeyIds,
HRESULT(GUID* key_ids, uint32_t key_ids_count));
MOCK_STDCALL_METHOD0(RefreshTrustedInput, HRESULT());
MOCK_STDCALL_METHOD2(ProcessContentEnabler,
HRESULT(IUnknown* request, IMFAsyncResult* result));
};
......@@ -101,8 +97,6 @@ class MediaFoundationRendererTest : public testing::Test {
mf_renderer_ = std::make_unique<MediaFoundationRenderer>(
/*muted=*/false, task_environment_.GetMainThreadTaskRunner());
// It is required to invoke SetPlaybackElementId() before Initialize().
mf_renderer_->SetPlaybackElementId(9876543210);
// Some default actions.
ON_CALL(cdm_context_, GetMediaFoundationCdmProxy(_))
......
......@@ -27,14 +27,12 @@ MediaFoundationSourceWrapper::~MediaFoundationSourceWrapper() {
key_ids[stream_id] = media_streams_[stream_id]->GetLastKeyId();
}
HRESULT hr = cdm_proxy_->SetLastKeyIds(playback_element_id_, key_ids.data(),
key_ids.size());
HRESULT hr = cdm_proxy_->SetLastKeyIds(key_ids.data(), key_ids.size());
DLOG_IF(ERROR, FAILED(hr))
<< "Failed to notify CDM proxy of last Key IDs: " << PrintHr(hr);
}
HRESULT MediaFoundationSourceWrapper::RuntimeClassInitialize(
uint64_t playback_element_id,
MediaResource* media_resource,
scoped_refptr<base::SequencedTaskRunner> task_runner) {
DVLOG_FUNC(1);
......@@ -57,7 +55,6 @@ HRESULT MediaFoundationSourceWrapper::RuntimeClassInitialize(
}
RETURN_IF_FAILED(MFCreateEventQueue(&mf_media_event_queue_));
playback_element_id_ = playback_element_id;
return S_OK;
}
......@@ -355,8 +352,7 @@ HRESULT MediaFoundationSourceWrapper::GetInputTrustAuthority(
// Use |nullptr| for content init_data and |0| for its size.
RETURN_IF_FAILED(cdm_proxy_->GetInputTrustAuthority(
playback_element_id_, stream_id, StreamCount(), nullptr, 0, riid,
object_out));
stream_id, StreamCount(), nullptr, 0, riid, object_out));
return S_OK;
}
......@@ -520,7 +516,7 @@ void MediaFoundationSourceWrapper::SetCdmProxy(IMFCdmProxy* cdm_proxy) {
DCHECK(!cdm_proxy_);
cdm_proxy_ = cdm_proxy;
HRESULT hr = cdm_proxy_->RefreshTrustedInput(playback_element_id_);
HRESULT hr = cdm_proxy_->RefreshTrustedInput();
DLOG_IF(ERROR, FAILED(hr))
<< "Failed to refresh trusted input: " << PrintHr(hr);
}
......
......@@ -44,7 +44,6 @@ class MediaFoundationSourceWrapper
void DetachResource();
HRESULT RuntimeClassInitialize(
uint64_t playback_element_id,
MediaResource* media_resource,
scoped_refptr<base::SequencedTaskRunner> task_runner);
......@@ -126,11 +125,13 @@ class MediaFoundationSourceWrapper
scoped_refptr<base::SequencedTaskRunner> task_runner_;
std::vector<Microsoft::WRL::ComPtr<MediaFoundationStreamWrapper>>
media_streams_;
// |mf_media_event_queue_| is safe to be called on any thread.
Microsoft::WRL::ComPtr<IMFMediaEventQueue> mf_media_event_queue_;
// The proxy interface to communicate with MFCdm.
Microsoft::WRL::ComPtr<IMFCdmProxy> cdm_proxy_;
uint64_t playback_element_id_ = 0;
bool video_stream_enabled_ = true;
float current_rate_ = 0.0f;
bool presentation_ended_ = false;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment