1
    2
    3
    4
    5
    6
    7
    8
    9
   10
   11
   12
   13
   14
   15
   16
   17
   18
   19
   20
   21
   22
   23
   24
   25
   26
   27
   28
   29
   30
   31
   32
   33
   34
   35
   36
   37
   38
   39

media / mojo / services / media_service.cc [blame]

// Copyright 2014 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "media/mojo/services/media_service.h"

#include "base/check.h"
#include "base/functional/bind.h"
#include "media/media_buildflags.h"
#include "media/mojo/mojom/interface_factory.mojom.h"
#include "media/mojo/services/interface_factory_impl.h"
#include "media/mojo/services/mojo_media_client.h"

namespace media {

MediaService::MediaService(std::unique_ptr<MojoMediaClient> mojo_media_client,
                           mojo::PendingReceiver<mojom::MediaService> receiver)
    : receiver_(this, std::move(receiver)),
      mojo_media_client_(std::move(mojo_media_client)) {
  DCHECK(mojo_media_client_);
  mojo_media_client_->Initialize();
}

MediaService::~MediaService() = default;

void MediaService::CreateInterfaceFactory(
    mojo::PendingReceiver<mojom::InterfaceFactory> receiver,
    mojo::PendingRemote<mojom::FrameInterfaceFactory> frame_interfaces) {
  // Ignore request if service has already stopped.
  if (!mojo_media_client_)
    return;

  interface_factory_receivers_.Add(
      std::make_unique<InterfaceFactoryImpl>(std::move(frame_interfaces),
                                             mojo_media_client_.get()),
      std::move(receiver));
}

}  // namespace media