Motown: wholesale clang-format R=kulakowski@chromium.org Review URL: https://codereview.chromium.org/1822333002 .
diff --git a/examples/media_test/keystroke.cc b/examples/media_test/keystroke.cc index 9e12063..0a7893d 100644 --- a/examples/media_test/keystroke.cc +++ b/examples/media_test/keystroke.cc
@@ -19,10 +19,10 @@ bool eat_newline = false; bool upped_already = false; -} // namespace +} // namespace char Keystroke(void) { - const char *kUp = "\033[A"; + const char* kUp = "\033[A"; fcntl(STDIN_FILENO, F_SETFL, fcntl(0, F_GETFL) | O_NONBLOCK); char buf[1];
diff --git a/examples/media_test/media_test.cc b/examples/media_test/media_test.cc index 206e959..0693a3f 100644 --- a/examples/media_test/media_test.cc +++ b/examples/media_test/media_test.cc
@@ -18,10 +18,9 @@ return std::unique_ptr<MediaTest>(new MediaTest(app, input_file_name)); } -MediaTest::MediaTest( - mojo::ApplicationImpl* app, - const std::string& input_file_name) : - state_(MediaState::UNPREPARED) { +MediaTest::MediaTest(mojo::ApplicationImpl* app, + const std::string& input_file_name) + : state_(MediaState::UNPREPARED) { MediaFactoryPtr factory; app->ConnectToService("mojo:media_factory", &factory); @@ -55,14 +54,12 @@ int64_t MediaTest::position_ns() const { // Apply the transform to the current time. int64_t position; - transform_.DoForwardTransform( - LocalClock::now().time_since_epoch().count(), - &position); + transform_.DoForwardTransform(LocalClock::now().time_since_epoch().count(), + &position); MOJO_DCHECK(position >= 0); - if (metadata_ && - static_cast<uint64_t>(position) > metadata_->duration) { + if (metadata_ && static_cast<uint64_t>(position) > metadata_->duration) { position = metadata_->duration; } @@ -73,9 +70,8 @@ return metadata_; } -void MediaTest::HandleStatusUpdates( - uint64_t version, - MediaPlayerStatusPtr status) { +void MediaTest::HandleStatusUpdates(uint64_t version, + MediaPlayerStatusPtr status) { if (status) { // Process status received from the player. state_ = status->state; @@ -84,11 +80,11 @@ // time. Note that 'reference' here refers to the presentation time, and // 'target' refers to the local time. if (status->timeline_transform) { - transform_ = LinearTransform( - status->timeline_transform->quad->target_offset, - status->timeline_transform->quad->reference_delta, - status->timeline_transform->quad->target_delta, - status->timeline_transform->quad->reference_offset); + transform_ = + LinearTransform(status->timeline_transform->quad->target_offset, + status->timeline_transform->quad->reference_delta, + status->timeline_transform->quad->target_delta, + status->timeline_transform->quad->reference_offset); } metadata_ = status->metadata.Pass(); @@ -100,8 +96,7 @@ // Request a status update. media_player_->GetStatus( - version, - [this](uint64_t version, MediaPlayerStatusPtr status) { + version, [this](uint64_t version, MediaPlayerStatusPtr status) { HandleStatusUpdates(version, status.Pass()); }); }
diff --git a/examples/media_test/media_test.h b/examples/media_test/media_test.h index 2c03118..0ae4c81 100644 --- a/examples/media_test/media_test.h +++ b/examples/media_test/media_test.h
@@ -21,9 +21,8 @@ public: using UpdateCallback = std::function<void()>; - static std::unique_ptr<MediaTest> Create( - mojo::ApplicationImpl* app, - const std::string& input_file_name); + static std::unique_ptr<MediaTest> Create(mojo::ApplicationImpl* app, + const std::string& input_file_name); ~MediaTest(); @@ -53,9 +52,8 @@ // Handles a status update from the player. When called with the default // argument values, initiates status updates. - void HandleStatusUpdates( - uint64_t version = MediaPlayer::kInitialStatus, - MediaPlayerStatusPtr status = nullptr); + void HandleStatusUpdates(uint64_t version = MediaPlayer::kInitialStatus, + MediaPlayerStatusPtr status = nullptr); MediaPlayerPtr media_player_; MediaState state_;
diff --git a/examples/media_test/media_test_app.cc b/examples/media_test/media_test_app.cc index b916f61..5db2771 100644 --- a/examples/media_test/media_test_app.cc +++ b/examples/media_test/media_test_app.cc
@@ -34,14 +34,15 @@ if (input_file_names_.empty()) { std::cout << "Please provide the names of the files you want to play;" - << " for example:" << std::endl; + << " for example:" << std::endl; std::cout << "mojo/devtools/common/mojo_run \\" << std::endl; std::cout << " \"https://core.mojoapps.io/media_test.mojo \\" - << std::endl; + << std::endl; std::cout << " file:///usr/local/google/home/you/superstition.ogg \\" - << std::endl; + << std::endl; std::cout << " file:///usr/local/google/home/you/higherground.ogg\"" - << std::endl << std::endl; + << std::endl + << std::endl; base::MessageLoop::current()->Quit(); return; } @@ -75,9 +76,9 @@ } private: - static const char *kHome; - static const char *kClearLine; - static const char *kUp; + static const char* kHome; + static const char* kClearLine; + static const char* kUp; static constexpr double ns_per_second = 1000000000.0; // Processes arguments. @@ -103,9 +104,8 @@ media_test_ = MediaTest::Create(app_, *input_file_names_iter_); metadata_shown_ = false; - media_test_->RegisterUpdateCallback([this]() { - HandleMediaTestUpdateCallback(); - }); + media_test_->RegisterUpdateCallback( + [this]() { HandleMediaTestUpdateCallback(); }); media_test_->Play(); } @@ -128,35 +128,36 @@ if (paint_) { // Move the cursor up the terminal so we paint over the old metadata // (7 lines) a blank line and the state line (total of 9 lines). - std::cout << kHome - << kUp << kUp << kUp << kUp << kUp << kUp << kUp << kUp << kUp; + std::cout << kHome << kUp << kUp << kUp << kUp << kUp << kUp << kUp << kUp + << kUp; } if (!paint_ && metadata_shown_) { // Do nothing. } else if (metadata) { metadata_shown_ = true; - std::cout << " duration " << std::setprecision(1) << - double(metadata->duration) / ns_per_second << " seconds" - << clear_line() << std::endl; - std::cout << " title " << - (metadata->title ? metadata->title : "<none>") - << clear_line() << std::endl; - std::cout << " artist " << - (metadata->artist ? metadata->artist : "<none>") - << clear_line() << std::endl; - std::cout << " album " << - (metadata->album ? metadata->album : "<none>") - << clear_line() << std::endl; - std::cout << " publisher " << - (metadata->publisher ? metadata->publisher : "<none>") - << clear_line() << std::endl; - std::cout << " genre " << - (metadata->genre ? metadata->genre : "<none>") - << clear_line() << std::endl; - std::cout << " composer " << - (metadata->composer ? metadata->composer : "<none>") - << clear_line() << std::endl << std::endl; + std::cout << " duration " << std::setprecision(1) + << double(metadata->duration) / ns_per_second << " seconds" + << clear_line() << std::endl; + std::cout << " title " + << (metadata->title ? metadata->title : "<none>") + << clear_line() << std::endl; + std::cout << " artist " + << (metadata->artist ? metadata->artist : "<none>") + << clear_line() << std::endl; + std::cout << " album " + << (metadata->album ? metadata->album : "<none>") + << clear_line() << std::endl; + std::cout << " publisher " + << (metadata->publisher ? metadata->publisher : "<none>") + << clear_line() << std::endl; + std::cout << " genre " + << (metadata->genre ? metadata->genre : "<none>") + << clear_line() << std::endl; + std::cout << " composer " + << (metadata->composer ? metadata->composer : "<none>") + << clear_line() << std::endl + << std::endl; } else { std::cout << " duration <none>" << kClearLine << std::endl; std::cout << " title <none>" << kClearLine << std::endl; @@ -198,7 +199,7 @@ quit_ = true; if (paint_) { std::cout << kHome << kUp << " quitting" << kClearLine << std::endl - << kClearLine << std::endl; + << kClearLine << std::endl; } else { std::cout << " quitting" << std::endl; } @@ -230,8 +231,8 @@ media_test_->Seek(position_ns); if (!paint_) { std::cout << " seeking to " << std::fixed << std::setprecision(1) - << double(position_ns) / ns_per_second - << " seconds " << std::endl; + << double(position_ns) / ns_per_second << " seconds " + << std::endl; } break; } @@ -283,13 +284,12 @@ if (paint_) { std::cout << kHome << " " << std::fixed << std::setprecision(1) - << double(media_test_->position_ns()) / ns_per_second - << " seconds " << kClearLine << std::flush; + << double(media_test_->position_ns()) / ns_per_second + << " seconds " << kClearLine << std::flush; } base::MessageLoop::current()->PostDelayedTask( - FROM_HERE, - base::Bind(&MediaTestApp::Poll, base::Unretained(this)), + FROM_HERE, base::Bind(&MediaTestApp::Poll, base::Unretained(this)), base::TimeDelta::FromMilliseconds(100)); } @@ -301,9 +301,7 @@ } } - const char* clear_line() const { - return paint_ ? kClearLine : ""; - } + const char* clear_line() const { return paint_ ? kClearLine : ""; } mojo::ApplicationImpl* app_; std::unique_ptr<MediaTest> media_test_; @@ -326,7 +324,7 @@ } // namespace mojo MojoResult MojoMain(MojoHandle application_request) { - mojo::ApplicationRunnerChromium - runner(new mojo::media::examples::MediaTestApp); + mojo::ApplicationRunnerChromium runner( + new mojo::media::examples::MediaTestApp); return runner.Run(application_request); }
diff --git a/mojo/services/media/common/cpp/fifo_allocator.cc b/mojo/services/media/common/cpp/fifo_allocator.cc index 0bbb69d..0823b44 100644 --- a/mojo/services/media/common/cpp/fifo_allocator.cc +++ b/mojo/services/media/common/cpp/fifo_allocator.cc
@@ -60,7 +60,7 @@ // Create a new region (allocated) of the requested size at the front of the // active region, and adjust the active region to reflect the deficit. MOJO_DCHECK(active_->size > size); - Region *allocated = get_free(true, size, active_->offset); + Region* allocated = get_free(true, size, active_->offset); active_->size -= size; active_->offset += size; insert_before(allocated, active_); @@ -69,17 +69,15 @@ void FifoAllocator::ReleaseRegion(uint64_t size, uint64_t offset) { // Start at active_->next. That's usually the region we're looking for. - bool released = - Release(size, offset, active_->next, nullptr) || - Release(size, offset, front_, active_); + bool released = Release(size, offset, active_->next, nullptr) || + Release(size, offset, front_, active_); MOJO_DCHECK(released); } -bool FifoAllocator::Release( - uint64_t size, - uint64_t offset, - Region* begin, - Region* end) { +bool FifoAllocator::Release(uint64_t size, + uint64_t offset, + Region* begin, + Region* end) { MOJO_DCHECK(begin != nullptr || end == nullptr); for (Region* region = begin; region != end; region = region->next) { if (region->offset == offset) { @@ -87,7 +85,7 @@ MOJO_DCHECK(region->size == size); region->allocated = false; - Region *prev = region->prev; + Region* prev = region->prev; if (prev != nullptr && !prev->allocated) { // Coalesce wtih the previous region. prev->size += region->size; @@ -96,7 +94,7 @@ region = prev; } - Region *next = region->next; + Region* next = region->next; if (next != nullptr && !next->allocated) { // Coalesce wtih the next region. next->offset = region->offset; @@ -118,9 +116,8 @@ bool FifoAllocator::AdvanceActive(uint64_t size) { MOJO_DCHECK(size != 0); - return - AdvanceActive(size, active_->next, nullptr) || - AdvanceActive(size, front_, active_); + return AdvanceActive(size, active_->next, nullptr) || + AdvanceActive(size, front_, active_); } bool FifoAllocator::AdvanceActive(uint64_t size, Region* begin, Region* end) { @@ -143,10 +140,8 @@ // If the old active region was at the back of the list, we'll be inserting // at the front, so make the offset zero. We insert at the front, because it's // a bit more efficient and because we don't need to implement insert_after. - Region *new_active = get_free( - false, - 0, - active_ == back_ ? 0 : active_->offset + active_->size); + Region* new_active = get_free( + false, 0, active_ == back_ ? 0 : active_->offset + active_->size); MOJO_DCHECK((active_ == back_) == (active_->next == nullptr)); insert_before(new_active, active_ == back_ ? front_ : active_->next); @@ -161,7 +156,7 @@ front_ = region->next; } else { MOJO_DCHECK(region->prev); - MOJO_DCHECK(region->prev->next ==region); + MOJO_DCHECK(region->prev->next == region); region->prev->next = region->next; } @@ -191,12 +186,13 @@ } } -FifoAllocator::Region* FifoAllocator::get_free( - bool allocated, uint64_t size, uint64_t offset) { +FifoAllocator::Region* FifoAllocator::get_free(bool allocated, + uint64_t size, + uint64_t offset) { MOJO_DCHECK(size <= size_); MOJO_DCHECK(offset <= size_ - size); - Region *result = free_; + Region* result = free_; if (result == nullptr) { result = new Region(); } else { @@ -212,7 +208,7 @@ void FifoAllocator::DeleteFrontToBack(Region* region) { while (region != nullptr) { - Region *to_delete = region; + Region* to_delete = region; region = region->next; delete to_delete; }
diff --git a/mojo/services/media/common/cpp/fifo_allocator.h b/mojo/services/media/common/cpp/fifo_allocator.h index 538223e..06e66e5 100644 --- a/mojo/services/media/common/cpp/fifo_allocator.h +++ b/mojo/services/media/common/cpp/fifo_allocator.h
@@ -55,31 +55,29 @@ // is very large and deallocation is frequently done out of order, the // sequential searches may be a performance issue. class FifoAllocator { - public: - // Returned by AllocatedRegion when the requested allocation cannot be - // performed. - static const uint64_t kNullOffset = std::numeric_limits<uint64_t>::max(); + public: + // Returned by AllocatedRegion when the requested allocation cannot be + // performed. + static const uint64_t kNullOffset = std::numeric_limits<uint64_t>::max(); - FifoAllocator(uint64_t size); + FifoAllocator(uint64_t size); - ~FifoAllocator(); + ~FifoAllocator(); - // Returns the size of the entire buffer as determined by the call to the - // constructor or the most recent call to Reset. - uint64_t size() const { - return size_; - } + // Returns the size of the entire buffer as determined by the call to the + // constructor or the most recent call to Reset. + uint64_t size() const { return size_; } - // Resets the buffer manager to its initial state (no regions allocated) - // with a new buffer size. Also deletes all the regions in the lookaside. - void Reset(uint64_t size); + // Resets the buffer manager to its initial state (no regions allocated) + // with a new buffer size. Also deletes all the regions in the lookaside. + void Reset(uint64_t size); - // Allocates a region and returns its offset or kNullOffset if the allocation - // could not be performed. - uint64_t AllocateRegion(uint64_t size); + // Allocates a region and returns its offset or kNullOffset if the allocation + // could not be performed. + uint64_t AllocateRegion(uint64_t size); - // Releases a previously-allocated region. - void ReleaseRegion(uint64_t size, uint64_t offset); + // Releases a previously-allocated region. + void ReleaseRegion(uint64_t size, uint64_t offset); private: // List element to track allocated and free regions.
diff --git a/mojo/services/media/common/cpp/mapped_shared_buffer.cc b/mojo/services/media/common/cpp/mapped_shared_buffer.cc index 976858a..491598a 100644 --- a/mojo/services/media/common/cpp/mapped_shared_buffer.cc +++ b/mojo/services/media/common/cpp/mapped_shared_buffer.cc
@@ -37,9 +37,8 @@ // TODO(johngro) : It would be nice if we could do something other than // DCHECK if things don't go exactly our way. MojoBufferInformation info; - MojoResult res = MojoGetBufferInformation(handle.get().value(), - &info, - sizeof(info)); + MojoResult res = + MojoGetBufferInformation(handle.get().value(), &info, sizeof(info)); uint64_t size = info.num_bytes; MOJO_DCHECK(res == MOJO_RESULT_OK); MOJO_DCHECK(size > 0); @@ -48,12 +47,9 @@ buffer_ptr_.reset(); void* ptr; - auto result = MapBuffer( - handle.get(), - 0, // offset - size, - &ptr, - MOJO_MAP_BUFFER_FLAG_NONE); + auto result = MapBuffer(handle.get(), + 0, // offset + size, &ptr, MOJO_MAP_BUFFER_FLAG_NONE); MOJO_DCHECK(result == MOJO_RESULT_OK); MOJO_DCHECK(ptr); @@ -93,7 +89,7 @@ return buffer_ptr_.get() + offset; } -uint64_t MappedSharedBuffer::OffsetFromPtr(void *ptr) const { +uint64_t MappedSharedBuffer::OffsetFromPtr(void* ptr) const { MOJO_DCHECK(buffer_ptr_); if (ptr == nullptr) { return FifoAllocator::kNullOffset;
diff --git a/mojo/services/media/common/cpp/mapped_shared_buffer.h b/mojo/services/media/common/cpp/mapped_shared_buffer.h index 9002393..5d218a7 100644 --- a/mojo/services/media/common/cpp/mapped_shared_buffer.h +++ b/mojo/services/media/common/cpp/mapped_shared_buffer.h
@@ -46,7 +46,7 @@ void* PtrFromOffset(uint64_t offset) const; // Translates a pointer into an offset. - uint64_t OffsetFromPtr(void *payload_ptr) const; + uint64_t OffsetFromPtr(void* payload_ptr) const; protected: void InitInternal(const ScopedSharedBufferHandle& handle); @@ -57,9 +57,7 @@ private: struct MappedBufferDeleter { - inline void operator()(uint8_t* ptr) const { - UnmapBuffer(ptr); - } + inline void operator()(uint8_t* ptr) const { UnmapBuffer(ptr); } }; // Size of the shared buffer.
diff --git a/mojo/services/media/common/cpp/shared_media_buffer_allocator.cc b/mojo/services/media/common/cpp/shared_media_buffer_allocator.cc index 0754203..03443a1 100644 --- a/mojo/services/media/common/cpp/shared_media_buffer_allocator.cc +++ b/mojo/services/media/common/cpp/shared_media_buffer_allocator.cc
@@ -16,5 +16,5 @@ fifo_allocator_.Reset(size()); } -} // namespace media -} // namespace mojo +} // namespace media +} // namespace mojo
diff --git a/mojo/services/media/common/cpp/shared_media_buffer_allocator.h b/mojo/services/media/common/cpp/shared_media_buffer_allocator.h index d7b7011..994e83f 100644 --- a/mojo/services/media/common/cpp/shared_media_buffer_allocator.h +++ b/mojo/services/media/common/cpp/shared_media_buffer_allocator.h
@@ -64,4 +64,4 @@ } // namespace media } // namespace mojo -#endif // MOJO_SERVICES_MEDIA_COMMON_CPP_MAPPED_SHARED_MEDIA_BUFFER_ALLOCATOR_H_ +#endif // MOJO_SERVICES_MEDIA_COMMON_CPP_MAPPED_SHARED_MEDIA_BUFFER_ALLOCATOR_H_
diff --git a/services/media/factory_service/audio_track_controller.cc b/services/media/factory_service/audio_track_controller.cc index 310c8d6..85733fc 100644 --- a/services/media/factory_service/audio_track_controller.cc +++ b/services/media/factory_service/audio_track_controller.cc
@@ -14,9 +14,8 @@ namespace mojo { namespace media { -AudioTrackController::AudioTrackController( - const String& url, - ApplicationImpl* app) { +AudioTrackController::AudioTrackController(const String& url, + ApplicationImpl* app) { // TODO(dalesat): Handle connection errors. DCHECK(app); @@ -50,5 +49,5 @@ callback(consumer.Pass(), rate_control.Pass()); } -} // namespace media -} // namespace mojo +} // namespace media +} // namespace mojo
diff --git a/services/media/factory_service/audio_track_controller.h b/services/media/factory_service/audio_track_controller.h index 64c587a..12fe7e6 100644 --- a/services/media/factory_service/audio_track_controller.h +++ b/services/media/factory_service/audio_track_controller.h
@@ -29,9 +29,8 @@ void GetSupportedMediaTypes(const GetSupportedMediaTypesCallback& callback); // Configures the controller. - void Configure( - const std::unique_ptr<StreamType>& stream_type, - const ConfigureCallback& callback); + void Configure(const std::unique_ptr<StreamType>& stream_type, + const ConfigureCallback& callback); private: AudioTrackPtr audio_track_;
diff --git a/services/media/factory_service/event.cc b/services/media/factory_service/event.cc index 3b6a324..c964407 100644 --- a/services/media/factory_service/event.cc +++ b/services/media/factory_service/event.cc
@@ -169,9 +169,7 @@ } } - std::function<void()> consequence = [this]() { - Finished(); - }; + std::function<void()> consequence = [this]() { Finished(); }; for (Event& precursor : precursors_) { precursor.When(consequence);
diff --git a/services/media/factory_service/event.h b/services/media/factory_service/event.h index b79630f..bc2b01e 100644 --- a/services/media/factory_service/event.h +++ b/services/media/factory_service/event.h
@@ -121,9 +121,7 @@ } // Determines whether this Event is non-null. - explicit operator bool() const { - return static_cast<bool>(impl_); - } + explicit operator bool() const { return static_cast<bool>(impl_); } // Executes the consequence when this Event occurs. If this Event hasn't // occurred or been cancelled when this method is called, a copy of the @@ -151,9 +149,7 @@ // Calls Occur. This method makes an Event convertible to // mojo::Callback<void()>. - void Run() const { - Occur(); - } + void Run() const { Occur(); } private: explicit Event(const std::shared_ptr<EventImpl>& impl);
diff --git a/services/media/factory_service/factory_service.cc b/services/media/factory_service/factory_service.cc index 0d0d9d7..9739165 100644 --- a/services/media/factory_service/factory_service.cc +++ b/services/media/factory_service/factory_service.cc
@@ -27,41 +27,34 @@ } bool MediaFactoryService::ConfigureIncomingConnection( - ApplicationConnection* connection) { + ApplicationConnection* connection) { connection->AddService<MediaFactory>(this); return true; } void MediaFactoryService::Create(ApplicationConnection* connection, - InterfaceRequest<MediaFactory> request) { + InterfaceRequest<MediaFactory> request) { bindings_.AddBinding(this, request.Pass()); } -void MediaFactoryService::CreatePlayer( - const String& origin_url, - InterfaceRequest<MediaPlayer> player) { +void MediaFactoryService::CreatePlayer(const String& origin_url, + InterfaceRequest<MediaPlayer> player) { products_.insert(std::static_pointer_cast<Product>( MediaPlayerImpl::Create(origin_url, player.Pass(), this))); } -void MediaFactoryService::CreateSource( - const String& origin_url, - Array<MediaTypeSetPtr> media_types, - InterfaceRequest<MediaSource> source) { +void MediaFactoryService::CreateSource(const String& origin_url, + Array<MediaTypeSetPtr> media_types, + InterfaceRequest<MediaSource> source) { products_.insert(std::static_pointer_cast<Product>( MediaSourceImpl::Create(origin_url, media_types, source.Pass(), this))); } -void MediaFactoryService::CreateSink( - const String& destination_url, - MediaTypePtr media_type, - InterfaceRequest<MediaSink> sink) { - products_.insert(std::static_pointer_cast<Product>( - MediaSinkImpl::Create( - destination_url, - media_type.Pass(), - sink.Pass(), - this))); +void MediaFactoryService::CreateSink(const String& destination_url, + MediaTypePtr media_type, + InterfaceRequest<MediaSink> sink) { + products_.insert(std::static_pointer_cast<Product>(MediaSinkImpl::Create( + destination_url, media_type.Pass(), sink.Pass(), this))); } void MediaFactoryService::CreateDecoder(
diff --git a/services/media/factory_service/factory_service.h b/services/media/factory_service/factory_service.h index 712a034..f1edd0e 100644 --- a/services/media/factory_service/factory_service.h +++ b/services/media/factory_service/factory_service.h
@@ -15,10 +15,9 @@ namespace mojo { namespace media { -class MediaFactoryService : - public ApplicationDelegate, - public InterfaceFactory<MediaFactory>, - public MediaFactory { +class MediaFactoryService : public ApplicationDelegate, + public InterfaceFactory<MediaFactory>, + public MediaFactory { public: // Provides common behavior for all objects created by the factory service. class Product : public std::enable_shared_from_this<Product> { @@ -51,32 +50,26 @@ // ApplicationDelegate implementation. void Initialize(ApplicationImpl* app) override; - bool ConfigureIncomingConnection( - ApplicationConnection* connection) override; + bool ConfigureIncomingConnection(ApplicationConnection* connection) override; // InterfaceFactory<MediaFactory> implementation. - void Create( - ApplicationConnection* connection, - InterfaceRequest<MediaFactory> request) override; + void Create(ApplicationConnection* connection, + InterfaceRequest<MediaFactory> request) override; // MediaFactory implementation. - void CreatePlayer( - const String& origin_url, - InterfaceRequest<MediaPlayer> player) override; + void CreatePlayer(const String& origin_url, + InterfaceRequest<MediaPlayer> player) override; - void CreateSource( - const String& origin_url, - Array<MediaTypeSetPtr> allowed_media_types, - InterfaceRequest<MediaSource> source) override; + void CreateSource(const String& origin_url, + Array<MediaTypeSetPtr> allowed_media_types, + InterfaceRequest<MediaSource> source) override; - void CreateSink( - const String& destination_url, - MediaTypePtr media_type, - InterfaceRequest<MediaSink> sink) override; + void CreateSink(const String& destination_url, + MediaTypePtr media_type, + InterfaceRequest<MediaSink> sink) override; - void CreateDecoder( - MediaTypePtr input_media_type, - InterfaceRequest<MediaTypeConverter> decoder) override; + void CreateDecoder(MediaTypePtr input_media_type, + InterfaceRequest<MediaTypeConverter> decoder) override; private: BindingSet<MediaFactory> bindings_;
diff --git a/services/media/factory_service/media_decoder_impl.cc b/services/media/factory_service/media_decoder_impl.cc index af77aac..7b08219 100644 --- a/services/media/factory_service/media_decoder_impl.cc +++ b/services/media/factory_service/media_decoder_impl.cc
@@ -14,16 +14,13 @@ MediaTypePtr input_media_type, InterfaceRequest<MediaTypeConverter> request, MediaFactoryService* owner) { - return std::shared_ptr<MediaDecoderImpl>(new MediaDecoderImpl( - input_media_type.Pass(), - request.Pass(), - owner)); + return std::shared_ptr<MediaDecoderImpl>( + new MediaDecoderImpl(input_media_type.Pass(), request.Pass(), owner)); } -MediaDecoderImpl::MediaDecoderImpl( - MediaTypePtr input_media_type, - InterfaceRequest<MediaTypeConverter> request, - MediaFactoryService* owner) +MediaDecoderImpl::MediaDecoderImpl(MediaTypePtr input_media_type, + InterfaceRequest<MediaTypeConverter> request, + MediaFactoryService* owner) : MediaFactoryService::Product(owner), binding_(this, request.Pass()), consumer_(MojoConsumer::Create()), @@ -31,9 +28,7 @@ DCHECK(input_media_type); // Go away when the client is no longer connected. - binding_.set_connection_error_handler([this]() { - ReleaseFromOwner(); - }); + binding_.set_connection_error_handler([this]() { ReleaseFromOwner(); }); std::unique_ptr<StreamType> input_stream_type = Convert(input_media_type); @@ -84,5 +79,5 @@ producer_->AddBinding(producer.Pass()); } -} // namespace media -} // namespace mojo +} // namespace media +} // namespace mojo
diff --git a/services/media/factory_service/media_decoder_impl.h b/services/media/factory_service/media_decoder_impl.h index 7b9258d..637d0f7 100644 --- a/services/media/factory_service/media_decoder_impl.h +++ b/services/media/factory_service/media_decoder_impl.h
@@ -19,9 +19,8 @@ namespace media { // Mojo agent that decodes a stream. -class MediaDecoderImpl - : public MediaFactoryService::Product, - public MediaTypeConverter { +class MediaDecoderImpl : public MediaFactoryService::Product, + public MediaTypeConverter { public: static std::shared_ptr<MediaDecoderImpl> Create( MediaTypePtr input_media_type, @@ -38,10 +37,9 @@ void GetProducer(InterfaceRequest<MediaProducer> producer) override; private: - MediaDecoderImpl( - MediaTypePtr input_media_type, - InterfaceRequest<MediaTypeConverter> request, - MediaFactoryService* owner); + MediaDecoderImpl(MediaTypePtr input_media_type, + InterfaceRequest<MediaTypeConverter> request, + MediaFactoryService* owner); Binding<MediaTypeConverter> binding_; Graph graph_;
diff --git a/services/media/factory_service/media_player_impl.cc b/services/media/factory_service/media_player_impl.cc index d2bc4e4..886dee1 100644 --- a/services/media/factory_service/media_player_impl.cc +++ b/services/media/factory_service/media_player_impl.cc
@@ -20,62 +20,57 @@ new MediaPlayerImpl(origin_url, request.Pass(), owner)); } -MediaPlayerImpl::MediaPlayerImpl( - const String& origin_url, - InterfaceRequest<MediaPlayer> request, - MediaFactoryService* owner) - : MediaFactoryService::Product(owner), - binding_(this, request.Pass()) { +MediaPlayerImpl::MediaPlayerImpl(const String& origin_url, + InterfaceRequest<MediaPlayer> request, + MediaFactoryService* owner) + : MediaFactoryService::Product(owner), binding_(this, request.Pass()) { DCHECK(origin_url); target_state_.SetWithConsequences(MediaState::PAUSED); target_position_.SetWithConsequences(kNotSeeking); // Go away when the client is no longer connected. - binding_.set_connection_error_handler([this]() { - ReleaseFromOwner(); - }); + binding_.set_connection_error_handler([this]() { ReleaseFromOwner(); }); app()->ConnectToService("mojo:media_factory", &factory_); - factory_->CreateSource( - origin_url, - nullptr, // allowed_media_types - GetProxy(&source_)); + factory_->CreateSource(origin_url, + nullptr, // allowed_media_types + GetProxy(&source_)); HandleSourceStatusUpdates(); source_->GetStreams( [this](mojo::Array<MediaSourceStreamDescriptorPtr> descriptors) { - // Populate streams_ and enable the streams we want. - std::vector<Event> stream_prepared_events; + // Populate streams_ and enable the streams we want. + std::vector<Event> stream_prepared_events; - for (MediaSourceStreamDescriptorPtr& descriptor : descriptors) { - streams_.push_back(std::unique_ptr<Stream>(new Stream())); - Stream& stream = *streams_.back(); - stream.descriptor_ = descriptor.Pass(); - switch (stream.descriptor_->media_type->scheme) { - case MediaTypeScheme::COMPRESSED_AUDIO: - case MediaTypeScheme::LPCM: - stream.enabled_ = true; - stream_prepared_events.push_back( - PrepareStream(streams_.back(), "mojo:audio_server")); - break; - // TODO(dalesat): Enable other stream types. - default: - break; - } - } + for (MediaSourceStreamDescriptorPtr& descriptor : descriptors) { + streams_.push_back(std::unique_ptr<Stream>(new Stream())); + Stream& stream = *streams_.back(); + stream.descriptor_ = descriptor.Pass(); + switch (stream.descriptor_->media_type->scheme) { + case MediaTypeScheme::COMPRESSED_AUDIO: + case MediaTypeScheme::LPCM: + stream.enabled_ = true; + stream_prepared_events.push_back( + PrepareStream(streams_.back(), "mojo:audio_server")); + break; + // TODO(dalesat): Enable other stream types. + default: + break; + } + } - event_ = Event::All(stream_prepared_events).When([this]() { - // The enabled streams are prepared. Prepare the source. - factory_.reset(); - source_->Prepare([this]() { - SetReportedMediaState(MediaState::PAUSED); - WhenPaused(); + event_ = Event::All(stream_prepared_events).When([this]() { + // The enabled streams are prepared. Prepare the source. + factory_.reset(); + source_->Prepare([this]() { + SetReportedMediaState(MediaState::PAUSED); + WhenPaused(); + }); + }); }); - }); - }); } MediaPlayerImpl::~MediaPlayerImpl() { @@ -86,11 +81,9 @@ Event seek_requested = target_position_.BecomesOtherThan(kNotSeeking); Event play_requested = target_state_.Becomes(MediaState::PLAYING); - event_ = Event::First({ seek_requested, play_requested }); + event_ = Event::First({seek_requested, play_requested}); - seek_requested.When([this]() { - WhenPausedAndSeeking(); - }); + seek_requested.When([this]() { WhenPausedAndSeeking(); }); play_requested.When([this]() { flushed_ = false; @@ -110,7 +103,7 @@ Event pause_requested = target_state_.Becomes(MediaState::PAUSED); Event sinks_ended = AllSinkStatesBecome(MediaState::ENDED); - event_ = Event::First({ seek_requested, pause_requested, sinks_ended }); + event_ = Event::First({seek_requested, pause_requested, sinks_ended}); seek_requested.When([this]() { event_ = ChangeSinkStates(MediaState::PAUSED).When([this]() { @@ -183,9 +176,8 @@ } } -void MediaPlayerImpl::GetStatus( - uint64_t version_last_seen, - const GetStatusCallback& callback) { +void MediaPlayerImpl::GetStatus(uint64_t version_last_seen, + const GetStatusCallback& callback) { if (version_last_seen < status_version_) { RunStatusCallback(callback); } else { @@ -206,95 +198,77 @@ target_position_.SetWithConsequences(position); } -Event MediaPlayerImpl::PrepareStream( - const std::unique_ptr<Stream>& stream, - const String& url) { +Event MediaPlayerImpl::PrepareStream(const std::unique_ptr<Stream>& stream, + const String& url) { DCHECK(factory_); Event event = Event::Create(); - source_->GetProducer( - stream->descriptor_->index, - GetProxy(&stream->encoded_producer_)); + source_->GetProducer(stream->descriptor_->index, + GetProxy(&stream->encoded_producer_)); if (stream->descriptor_->media_type->scheme == MediaTypeScheme::COMPRESSED_AUDIO) { // Compressed audio. Insert a decoder in front of the sink. The sink would // add its own internal decoder, but we want to test the decoder. - factory_->CreateDecoder( - stream->descriptor_->media_type.Clone(), - GetProxy(&stream->decoder_)); + factory_->CreateDecoder(stream->descriptor_->media_type.Clone(), + GetProxy(&stream->decoder_)); MediaConsumerPtr decoder_consumer; stream->decoder_->GetConsumer(GetProxy(&decoder_consumer)); Event connect_complete = Event::Create(); - stream->encoded_producer_->Connect( - decoder_consumer.Pass(), - [&stream, connect_complete]() { - stream->encoded_producer_.reset(); - connect_complete.Occur(); - }); + stream->encoded_producer_->Connect(decoder_consumer.Pass(), + [&stream, connect_complete]() { + stream->encoded_producer_.reset(); + connect_complete.Occur(); + }); stream->decoder_->GetOutputType( [this, &stream, url, event](MediaTypePtr output_type) { stream->decoder_->GetProducer(GetProxy(&stream->decoded_producer_)); - CreateSink( - stream, - output_type, - url, - event); + CreateSink(stream, output_type, url, event); }); - return Event::All({ connect_complete, event }); + return Event::All({connect_complete, event}); } else { // Uncompressed audio. Connect the source stream directly to the sink. This // would work for compressed audio as well (the sink would decode), but we // want to test the decoder. DCHECK(stream->descriptor_->media_type->scheme == MediaTypeScheme::LPCM); stream->decoded_producer_ = stream->encoded_producer_.Pass(); - CreateSink( - stream, - stream->descriptor_->media_type, - url, - event); + CreateSink(stream, stream->descriptor_->media_type, url, event); return event; } } -void MediaPlayerImpl::CreateSink( - const std::unique_ptr<Stream>& stream, - const MediaTypePtr& input_media_type, - const String& url, - Event event) { +void MediaPlayerImpl::CreateSink(const std::unique_ptr<Stream>& stream, + const MediaTypePtr& input_media_type, + const String& url, + Event event) { DCHECK(input_media_type); DCHECK(stream->decoded_producer_); DCHECK(factory_); - factory_->CreateSink( - url, - input_media_type.Clone(), - GetProxy(&stream->sink_)); + factory_->CreateSink(url, input_media_type.Clone(), GetProxy(&stream->sink_)); MediaConsumerPtr consumer; stream->sink_->GetConsumer(GetProxy(&consumer)); - stream->decoded_producer_->Connect( - consumer.Pass(), - [this, event, &stream]() { - stream->decoded_producer_.reset(); + stream->decoded_producer_->Connect(consumer.Pass(), [this, event, &stream]() { + stream->decoded_producer_.reset(); - DCHECK(stream->state_ == MediaState::UNPREPARED); - DCHECK(reported_media_state_ == MediaState::UNPREPARED || - reported_media_state_ == MediaState::FAULT); + DCHECK(stream->state_ == MediaState::UNPREPARED); + DCHECK(reported_media_state_ == MediaState::UNPREPARED || + reported_media_state_ == MediaState::FAULT); - stream->state_.SetWithConsequences(MediaState::PAUSED); + stream->state_.SetWithConsequences(MediaState::PAUSED); - HandleSinkStatusUpdates(stream); + HandleSinkStatusUpdates(stream); - event.Occur(); - }); + event.Occur(); + }); } void MediaPlayerImpl::StatusUpdated() { @@ -305,8 +279,8 @@ } } -void MediaPlayerImpl::RunStatusCallback(const GetStatusCallback& callback) - const { +void MediaPlayerImpl::RunStatusCallback( + const GetStatusCallback& callback) const { MediaPlayerStatusPtr status = MediaPlayerStatus::New(); status->state = reported_media_state_; status->timeline_transform = transform_.Clone(); @@ -314,19 +288,17 @@ callback.Run(status_version_, status.Pass()); } -void MediaPlayerImpl::HandleSourceStatusUpdates( - uint64_t version, - MediaSourceStatusPtr status) { +void MediaPlayerImpl::HandleSourceStatusUpdates(uint64_t version, + MediaSourceStatusPtr status) { if (status) { metadata_ = status->metadata.Pass(); StatusUpdated(); } - source_->GetStatus( - version, - [this](uint64_t version, MediaSourceStatusPtr status) { - HandleSourceStatusUpdates(version, status.Pass()); - }); + source_->GetStatus(version, + [this](uint64_t version, MediaSourceStatusPtr status) { + HandleSourceStatusUpdates(version, status.Pass()); + }); } void MediaPlayerImpl::HandleSinkStatusUpdates( @@ -342,8 +314,7 @@ } stream->sink_->GetStatus( - version, - [this, &stream](uint64_t version, MediaSinkStatusPtr status) { + version, [this, &stream](uint64_t version, MediaSinkStatusPtr status) { HandleSinkStatusUpdates(stream, version, status.Pass()); }); } @@ -354,5 +325,5 @@ MediaPlayerImpl::Stream::~Stream() {} -} // namespace media -} // namespace mojo +} // namespace media +} // namespace mojo
diff --git a/services/media/factory_service/media_player_impl.h b/services/media/factory_service/media_player_impl.h index b3b3c9e..d1bde49 100644 --- a/services/media/factory_service/media_player_impl.h +++ b/services/media/factory_service/media_player_impl.h
@@ -20,9 +20,8 @@ namespace media { // Mojo agent that renders streams from an origin specified by URL. -class MediaPlayerImpl - : public MediaFactoryService::Product, - public MediaPlayer { +class MediaPlayerImpl : public MediaFactoryService::Product, + public MediaPlayer { public: static std::shared_ptr<MediaPlayerImpl> Create( const String& originUrl, @@ -32,8 +31,8 @@ ~MediaPlayerImpl() override; // MediaPlayer implementation. - void GetStatus(uint64_t version_last_seen, const GetStatusCallback& callback) - override; + void GetStatus(uint64_t version_last_seen, + const GetStatusCallback& callback) override; void Play() override; @@ -56,10 +55,9 @@ MediaProducerPtr decoded_producer_; }; - MediaPlayerImpl( - const String& originUrl, - InterfaceRequest<MediaPlayer> request, - MediaFactoryService* owner); + MediaPlayerImpl(const String& originUrl, + InterfaceRequest<MediaPlayer> request, + MediaFactoryService* owner); // Handles events in paused state. void WhenPaused(); @@ -88,11 +86,10 @@ // Creates a sink for a stream. // TODO(dalesat): Use raw pointers rather than const std::unique_ptr<>&. - void CreateSink( - const std::unique_ptr<Stream>& stream, - const MediaTypePtr& input_media_type, - const String& url, - Event event); + void CreateSink(const std::unique_ptr<Stream>& stream, + const MediaTypePtr& input_media_type, + const String& url, + Event event); // Increments the status version and runs pending status request callbacks. void StatusUpdated(); @@ -102,16 +99,14 @@ // Handles a status update from the source. When called with the default // argument values, initiates source status updates. - void HandleSourceStatusUpdates( - uint64_t version = MediaSource::kInitialStatus, - MediaSourceStatusPtr status = nullptr); + void HandleSourceStatusUpdates(uint64_t version = MediaSource::kInitialStatus, + MediaSourceStatusPtr status = nullptr); // Handles a status update from a sink. When called with the default // argument values, initiates sink status updates. - void HandleSinkStatusUpdates( - const std::unique_ptr<Stream>& stream, - uint64_t version = MediaSink::kInitialStatus, - MediaSinkStatusPtr status = nullptr); + void HandleSinkStatusUpdates(const std::unique_ptr<Stream>& stream, + uint64_t version = MediaSink::kInitialStatus, + MediaSinkStatusPtr status = nullptr); Event event_; Binding<MediaPlayer> binding_;
diff --git a/services/media/factory_service/media_sink_impl.cc b/services/media/factory_service/media_sink_impl.cc index b32121e..7ac4bf3 100644 --- a/services/media/factory_service/media_sink_impl.cc +++ b/services/media/factory_service/media_sink_impl.cc
@@ -19,17 +19,13 @@ InterfaceRequest<MediaSink> request, MediaFactoryService* owner) { return std::shared_ptr<MediaSinkImpl>(new MediaSinkImpl( - destination_url, - media_type.Pass(), - request.Pass(), - owner)); + destination_url, media_type.Pass(), request.Pass(), owner)); } -MediaSinkImpl::MediaSinkImpl( - const String& destination_url, - MediaTypePtr media_type, - InterfaceRequest<MediaSink> request, - MediaFactoryService* owner) +MediaSinkImpl::MediaSinkImpl(const String& destination_url, + MediaTypePtr media_type, + InterfaceRequest<MediaSink> request, + MediaFactoryService* owner) : MediaFactoryService::Product(owner), binding_(this, request.Pass()), consumer_(MojoConsumer::Create()), @@ -38,9 +34,7 @@ DCHECK(media_type); // Go away when the client is no longer connected. - binding_.set_connection_error_handler([this]() { - ReleaseFromOwner(); - }); + binding_.set_connection_error_handler([this]() { ReleaseFromOwner(); }); // TODO(dalesat): Support file and network urls. // TODO(dalesat): Support mojo services in a reasonable way. @@ -65,14 +59,13 @@ }); }); - producer_->SetStatusCallback( - [this](MediaState state) { - producer_state_ = state; - StatusUpdated(); - if (state == MediaState::ENDED) { - Pause(); - } - }); + producer_->SetStatusCallback([this](MediaState state) { + producer_state_ = state; + StatusUpdated(); + if (state == MediaState::ENDED) { + Pause(); + } + }); if (destination_url != "mojo:audio_server") { LOG(ERROR) << "mojo:audio_server is the only supported destination"; @@ -83,68 +76,63 @@ } // TODO(dalesat): Once we have c++14, get rid of this shared pointer hack. - std::shared_ptr<StreamType> - captured_stream_type(Convert(media_type).release()); + std::shared_ptr<StreamType> captured_stream_type( + Convert(media_type).release()); // An AudioTrackController knows how to talk to an audio track, interrogating // it for supported stream types and configuring it for the chosen stream // type. controller_.reset(new AudioTrackController(destination_url, app())); - controller_->GetSupportedMediaTypes( - [this, consumer_ref, producer_ref, captured_stream_type] - (std::unique_ptr<std::vector<std::unique_ptr<StreamTypeSet>>> + controller_->GetSupportedMediaTypes([this, consumer_ref, producer_ref, + captured_stream_type]( + std::unique_ptr<std::vector<std::unique_ptr<StreamTypeSet>>> supported_stream_types) { - std::unique_ptr<StreamType> producer_stream_type; + std::unique_ptr<StreamType> producer_stream_type; - // Add transforms to the pipeline to convert from stream_type to a - // type supported by the track. - OutputRef out = consumer_ref.output(); - bool result = BuildConversionPipeline( - *captured_stream_type, - *supported_stream_types, - &graph_, - &out, - &producer_stream_type); - if (!result) { - // Failed to build conversion pipeline. - producer_state_ = MediaState::FAULT; - StatusUpdated(); - return; - } + // Add transforms to the pipeline to convert from stream_type to a + // type supported by the track. + OutputRef out = consumer_ref.output(); + bool result = + BuildConversionPipeline(*captured_stream_type, *supported_stream_types, + &graph_, &out, &producer_stream_type); + if (!result) { + // Failed to build conversion pipeline. + producer_state_ = MediaState::FAULT; + StatusUpdated(); + return; + } - graph_.ConnectOutputToPart(out, producer_ref); + graph_.ConnectOutputToPart(out, producer_ref); - switch (producer_stream_type->scheme()) { - case StreamType::Scheme::kLpcm: - frames_per_second_ = - producer_stream_type->lpcm()->frames_per_second(); - break; - case StreamType::Scheme::kCompressedAudio: - frames_per_second_ = - producer_stream_type->compressed_audio()->frames_per_second(); - break; - default: - // Unsupported producer stream type. - producer_state_ = MediaState::FAULT; - StatusUpdated(); - return; - } + switch (producer_stream_type->scheme()) { + case StreamType::Scheme::kLpcm: + frames_per_second_ = producer_stream_type->lpcm()->frames_per_second(); + break; + case StreamType::Scheme::kCompressedAudio: + frames_per_second_ = + producer_stream_type->compressed_audio()->frames_per_second(); + break; + default: + // Unsupported producer stream type. + producer_state_ = MediaState::FAULT; + StatusUpdated(); + return; + } - controller_->Configure( - std::move(producer_stream_type), - [this] - (MediaConsumerPtr consumer, RateControlPtr rate_control) { - DCHECK(consumer); - DCHECK(rate_control); - rate_control_ = rate_control.Pass(); - producer_->Connect(consumer.Pass(), [this]() { - graph_.Prepare(); - ready_.Occur(); - MaybeSetRate(); - }); - }); - }); + controller_->Configure( + std::move(producer_stream_type), + [this](MediaConsumerPtr consumer, RateControlPtr rate_control) { + DCHECK(consumer); + DCHECK(rate_control); + rate_control_ = rate_control.Pass(); + producer_->Connect(consumer.Pass(), [this]() { + graph_.Prepare(); + ready_.Occur(); + MaybeSetRate(); + }); + }); + }); } MediaSinkImpl::~MediaSinkImpl() {} @@ -167,9 +155,8 @@ consumer_->AddBinding(consumer.Pass()); } -void MediaSinkImpl::GetStatus( - uint64_t version_last_seen, - const GetStatusCallback& callback) { +void MediaSinkImpl::GetStatus(uint64_t version_last_seen, + const GetStatusCallback& callback) { if (version_last_seen < status_version_) { RunStatusCallback(callback); } else { @@ -197,9 +184,9 @@ void MediaSinkImpl::RunStatusCallback(const GetStatusCallback& callback) const { MediaSinkStatusPtr status = MediaSinkStatus::New(); - status->state = (producer_state_ == MediaState::PAUSED && rate_ != 0.0) ? - MediaState::PLAYING : - producer_state_; + status->state = (producer_state_ == MediaState::PAUSED && rate_ != 0.0) + ? MediaState::PLAYING + : producer_state_; status->timeline_transform = status_transform_.Clone(); callback.Run(status_version_, status.Pass()); } @@ -216,17 +203,13 @@ static_cast<uint32_t>(frames_per_second_ * target_rate_), 1); // Local time rate in seconds_per_tick. - LinearTransform::Ratio local_seconds_per_tick( - LocalDuration::period::num, - LocalDuration::period::den); + LinearTransform::Ratio local_seconds_per_tick(LocalDuration::period::num, + LocalDuration::period::den); // Desired rate in frames per local tick. LinearTransform::Ratio rate_frames_per_tick; - bool success = - LinearTransform::Ratio::Compose( - local_seconds_per_tick, - rate_frames_per_second, - &rate_frames_per_tick); + bool success = LinearTransform::Ratio::Compose( + local_seconds_per_tick, rate_frames_per_second, &rate_frames_per_tick); DCHECK(success) << "LinearTransform::Ratio::Compose reports loss of precision"; @@ -234,13 +217,12 @@ // For now, it's hard-coded to be 30ms in the future. // The local time when we want the rate to change. int64_t start_local_time = - (LocalClock::now().time_since_epoch() + std::chrono::milliseconds(30)). - count(); + (LocalClock::now().time_since_epoch() + std::chrono::milliseconds(30)) + .count(); // The media time corresponding to start_local_time. int64_t start_media_time; - if (flushed_ && - producer_->GetFirstPtsSinceFlush() != Packet::kUnknownPts) { + if (flushed_ && producer_->GetFirstPtsSinceFlush() != Packet::kUnknownPts) { // We're getting started initially or after a flush/prime, so the media // time corresponding to start_local_time should be the PTS of // the first packet. @@ -272,10 +254,9 @@ // Get the frame rate in frames per local tick. LinearTransform::Ratio frame_rate_frames_per_second(frames_per_second_, 1); LinearTransform::Ratio frame_rate_frames_per_tick; - success = LinearTransform::Ratio::Compose( - local_seconds_per_tick, - frame_rate_frames_per_second, - &frame_rate_frames_per_tick); + success = LinearTransform::Ratio::Compose(local_seconds_per_tick, + frame_rate_frames_per_second, + &frame_rate_frames_per_tick); DCHECK(success) << "LinearTransform::Ratio::Compose reports loss of precision"; @@ -289,8 +270,7 @@ // Translate the current transform quad so the presentation time units // are the same as the local time units. success = local_to_presentation.DoReverseTransform( - start_media_time, - &status_transform_->quad->reference_offset); + start_media_time, &status_transform_->quad->reference_offset); DCHECK(success) << "LinearTransform::DoReverseTransform reports loss of precision"; status_transform_->quad->target_offset = start_local_time; @@ -303,13 +283,12 @@ status_transform_->quad->reference_delta = static_cast<int32_t>(presentation_delta); status_transform_->quad->target_delta = rate_frames_per_tick.denominator; - LinearTransform::Ratio::Reduce( - &status_transform_->quad->reference_delta, - &status_transform_->quad->target_delta); + LinearTransform::Ratio::Reduce(&status_transform_->quad->reference_delta, + &status_transform_->quad->target_delta); rate_ = target_rate_; StatusUpdated(); } -} // namespace media -} // namespace mojo +} // namespace media +} // namespace mojo
diff --git a/services/media/factory_service/media_sink_impl.h b/services/media/factory_service/media_sink_impl.h index d021119..514319b 100644 --- a/services/media/factory_service/media_sink_impl.h +++ b/services/media/factory_service/media_sink_impl.h
@@ -25,9 +25,7 @@ // Mojo agent that consumes a stream and delivers it to a destination specified // by URL. -class MediaSinkImpl - : public MediaFactoryService::Product, - public MediaSink { +class MediaSinkImpl : public MediaFactoryService::Product, public MediaSink { public: static std::shared_ptr<MediaSinkImpl> Create( const String& destination_url, @@ -38,8 +36,8 @@ ~MediaSinkImpl() override; // MediaSink implementation. - void GetClockDisposition(const GetClockDispositionCallback& callback) - override; + void GetClockDisposition( + const GetClockDispositionCallback& callback) override; void GetMasterClock(InterfaceRequest<Clock> master_clock) override; @@ -47,19 +45,18 @@ void GetConsumer(InterfaceRequest<MediaConsumer> consumer) override; - void GetStatus(uint64_t version_last_seen, const GetStatusCallback& callback) - override; + void GetStatus(uint64_t version_last_seen, + const GetStatusCallback& callback) override; void Play() override; void Pause() override; private: - MediaSinkImpl( - const String& destination_url, - MediaTypePtr media_type, - InterfaceRequest<MediaSink> request, - MediaFactoryService* owner); + MediaSinkImpl(const String& destination_url, + MediaTypePtr media_type, + InterfaceRequest<MediaSink> request, + MediaFactoryService* owner); // Increments the status version and runs pending status request callbacks. void StatusUpdated();
diff --git a/services/media/factory_service/media_source_impl.cc b/services/media/factory_service/media_source_impl.cc index 7194414..9cfc60e 100644 --- a/services/media/factory_service/media_source_impl.cc +++ b/services/media/factory_service/media_source_impl.cc
@@ -21,10 +21,7 @@ InterfaceRequest<MediaSource> request, MediaFactoryService* owner) { return std::shared_ptr<MediaSourceImpl>(new MediaSourceImpl( - origin_url, - allowed_media_types, - request.Pass(), - owner)); + origin_url, allowed_media_types, request.Pass(), owner)); } MediaSourceImpl::MediaSourceImpl( @@ -32,14 +29,11 @@ const Array<MediaTypeSetPtr>& allowed_media_types, InterfaceRequest<MediaSource> request, MediaFactoryService* owner) - : MediaFactoryService::Product(owner), - binding_(this, request.Pass()) { + : MediaFactoryService::Product(owner), binding_(this, request.Pass()) { DCHECK(origin_url); // Go away when the client is no longer connected. - binding_.set_connection_error_handler([this]() { - ReleaseFromOwner(); - }); + binding_.set_connection_error_handler([this]() { ReleaseFromOwner(); }); GURL gurl = GURL(origin_url); @@ -64,10 +58,8 @@ auto demux_streams = demux_->streams(); for (auto demux_stream : demux_streams) { streams_.push_back(std::unique_ptr<Stream>(new Stream( - demux_part_.output(demux_stream->index()), - demux_stream->stream_type(), - Convert(allowed_media_types), - &graph_))); + demux_part_.output(demux_stream->index()), demux_stream->stream_type(), + Convert(allowed_media_types), &graph_))); } } @@ -100,9 +92,8 @@ // TODO(dalesat): Is this needed? } -void MediaSourceImpl::GetProducer( - uint32_t stream_index, - InterfaceRequest<MediaProducer> producer) { +void MediaSourceImpl::GetProducer(uint32_t stream_index, + InterfaceRequest<MediaProducer> producer) { if (stream_index >= streams_.size()) { return; } @@ -120,9 +111,8 @@ streams_[stream_index]->GetPullModeProducer(producer.Pass()); } -void MediaSourceImpl::GetStatus( - uint64_t version_last_seen, - const GetStatusCallback& callback) { +void MediaSourceImpl::GetStatus(uint64_t version_last_seen, + const GetStatusCallback& callback) { if (version_last_seen < status_version_) { RunStatusCallback(callback); } else { @@ -152,9 +142,7 @@ Event all_streams_primed = Event::All(stream_primed_events); // Capture all_streams_primed so it doesn't get deleted before it occurs. - all_streams_primed.When([callback, all_streams_primed]() { - callback.Run(); - }); + all_streams_primed.When([callback, all_streams_primed]() { callback.Run(); }); } void MediaSourceImpl::Flush(const FlushCallback& callback) { @@ -171,9 +159,8 @@ Event all_streams_flushed = Event::All(stream_flushed_events); // Capture all_streams_flushed so it doesn't get deleted before it occurs. - all_streams_flushed.When([callback, all_streams_flushed]() { - callback.Run(); - }); + all_streams_flushed.When( + [callback, all_streams_flushed]() { callback.Run(); }); } void MediaSourceImpl::Seek(int64_t position, const FlushCallback& callback) { @@ -189,8 +176,8 @@ } } -void MediaSourceImpl::RunStatusCallback(const GetStatusCallback& callback) - const { +void MediaSourceImpl::RunStatusCallback( + const GetStatusCallback& callback) const { MediaSourceStatusPtr status = MediaSourceStatus::New(); status->state = state_; status->metadata = demux_ ? Convert(demux_->metadata()) : nullptr; @@ -202,9 +189,8 @@ std::unique_ptr<StreamType> stream_type, const std::unique_ptr<std::vector<std::unique_ptr<StreamTypeSet>>>& allowed_stream_types, - Graph* graph) : - original_stream_type_(std::move(stream_type)), - graph_(graph) { + Graph* graph) + : original_stream_type_(std::move(stream_type)), graph_(graph) { DCHECK(original_stream_type_); DCHECK(graph); @@ -213,12 +199,9 @@ if (allowed_stream_types == nullptr) { // No conversion requested. stream_type_ = SafeClone(original_stream_type_); - } else if (!BuildConversionPipeline( - *original_stream_type_, - *allowed_stream_types, - graph, - &output_, - &stream_type_)) { + } else if (!BuildConversionPipeline(*original_stream_type_, + *allowed_stream_types, graph, &output_, + &stream_type_)) { // Can't convert to any allowed type. stream_type_ = StreamType::Create(StreamType::Scheme::kNone); } @@ -265,7 +248,7 @@ } void MediaSourceImpl::Stream::EnsureSink() { - if (producer_ == nullptr && pull_mode_producer_ == nullptr) { + if (producer_ == nullptr && pull_mode_producer_ == nullptr) { null_sink_ = NullSink::Create(); graph_->ConnectOutputToPart(output_, graph_->Add(null_sink_)); } @@ -285,5 +268,5 @@ } } -} // namespace media -} // namespace mojo +} // namespace media +} // namespace mojo
diff --git a/services/media/factory_service/media_source_impl.h b/services/media/factory_service/media_source_impl.h index 6df1eaf..ac879b0 100644 --- a/services/media/factory_service/media_source_impl.h +++ b/services/media/factory_service/media_source_impl.h
@@ -22,9 +22,8 @@ namespace media { // Mojo agent that produces streams from an origin specified by URL. -class MediaSourceImpl - : public MediaFactoryService::Product, - public MediaSource { +class MediaSourceImpl : public MediaFactoryService::Product, + public MediaSource { public: static std::shared_ptr<MediaSourceImpl> Create( const String& origin_url, @@ -37,23 +36,22 @@ // MediaSource implementation. void GetStreams(const GetStreamsCallback& callback) override; - void GetClockDisposition(const GetClockDispositionCallback& callback) - override; + void GetClockDisposition( + const GetClockDispositionCallback& callback) override; void GetMasterClock(InterfaceRequest<Clock> master_clock) override; void SetMasterClock(InterfaceHandle<Clock> master_clock) override; - void GetProducer( - uint32_t stream_index, - InterfaceRequest<MediaProducer> producer) override; + void GetProducer(uint32_t stream_index, + InterfaceRequest<MediaProducer> producer) override; void GetPullModeProducer( uint32_t stream_index, InterfaceRequest<MediaPullModeProducer> producer) override; - void GetStatus(uint64_t version_last_seen, const GetStatusCallback& callback) - override; + void GetStatus(uint64_t version_last_seen, + const GetStatusCallback& callback) override; void Prepare(const PrepareCallback& callback) override; @@ -64,20 +62,18 @@ void Seek(int64_t position, const SeekCallback& callback) override; private: - MediaSourceImpl( - const String& origin_url, - const Array<MediaTypeSetPtr>& allowed_media_types, - InterfaceRequest<MediaSource> request, - MediaFactoryService* owner); + MediaSourceImpl(const String& origin_url, + const Array<MediaTypeSetPtr>& allowed_media_types, + InterfaceRequest<MediaSource> request, + MediaFactoryService* owner); class Stream { public: - Stream( - OutputRef output, - std::unique_ptr<StreamType> stream_type, - const std::unique_ptr<std::vector<std::unique_ptr<StreamTypeSet>>>& - allowed_stream_types, - Graph* graph); + Stream(OutputRef output, + std::unique_ptr<StreamType> stream_type, + const std::unique_ptr<std::vector<std::unique_ptr<StreamTypeSet>>>& + allowed_stream_types, + Graph* graph); ~Stream(); @@ -91,8 +87,7 @@ void GetProducer(InterfaceRequest<MediaProducer> producer); // Gets the pull mode producer. - void GetPullModeProducer( - InterfaceRequest<MediaPullModeProducer> producer); + void GetPullModeProducer(InterfaceRequest<MediaPullModeProducer> producer); // Makes sure the stream has a sink. void EnsureSink();
diff --git a/services/media/factory_service/rule_set.cc b/services/media/factory_service/rule_set.cc index db8b582..baceeaf 100644 --- a/services/media/factory_service/rule_set.cc +++ b/services/media/factory_service/rule_set.cc
@@ -19,7 +19,7 @@ if (condition()) { event.Occur(); } else { - CheckRules(); // To purge occurred/cancelled events. + CheckRules(); // To purge occurred/cancelled events. rules_.push_back(Rule(condition, event)); }
diff --git a/services/media/factory_service/watched.h b/services/media/factory_service/watched.h index 74d2578..c53367d 100644 --- a/services/media/factory_service/watched.h +++ b/services/media/factory_service/watched.h
@@ -11,7 +11,8 @@ namespace media { // Wraps an object, providing Events that occur when certain criteria are met. -template<typename T> class Watched : public RuleSet { +template <typename T> +class Watched : public RuleSet { public: Watched() {} explicit Watched(T t) : t_(t) {} @@ -19,18 +20,14 @@ // Returns a Event that will occur when the value of this Watched changes // to comparand (immediately if they're already equal). Event Becomes(const T& comparand) { - return AddRule([this, comparand]() -> bool { - return t_ == comparand; - }); + return AddRule([this, comparand]() -> bool { return t_ == comparand; }); } // Returns a Event that will occur when the value of this Watched changes // to something other than comparand (immediately if they're already not // equal). Event BecomesOtherThan(const T& comparand) { - return AddRule([this, comparand]() -> bool { - return t_ != comparand; - }); + return AddRule([this, comparand]() -> bool { return t_ != comparand; }); } void SetWithConsequences(const T& t) { @@ -38,13 +35,9 @@ CheckRules(); } - operator T() { - return t_; - } + operator T() { return t_; } - operator const T&() const { - return t_; - } + operator const T&() const { return t_; } private: T t_;
diff --git a/services/media/framework/conversion_pipeline_builder.cc b/services/media/framework/conversion_pipeline_builder.cc index 2f21eef..dfef3b8 100644 --- a/services/media/framework/conversion_pipeline_builder.cc +++ b/services/media/framework/conversion_pipeline_builder.cc
@@ -13,22 +13,21 @@ namespace { enum class AddResult { - kFailed, // Can't convert. - kProgressed, // Added a conversion transform. - kFinished // Done adding conversion transforms. + kFailed, // Can't convert. + kProgressed, // Added a conversion transform. + kFinished // Done adding conversion transforms. }; // Produces a score for in_type with respect to out_type_set. The score // is used to compare type sets to see which represents the best goal for // conversion. Higher scores are preferred. A score of zero indicates that // in_type is incompatible with out_type_set. -int Score( - const LpcmStreamType& in_type, - const LpcmStreamTypeSet& out_type_set) { +int Score(const LpcmStreamType& in_type, + const LpcmStreamTypeSet& out_type_set) { // TODO(dalesat): Plenty of room for more subtlety here. Maybe actually // measure conversion costs (cpu, quality, etc) and reflect them here. - int score = 1; // We can convert anything, so 1 is the minimum score. + int score = 1; // We can convert anything, so 1 is the minimum score. if (in_type.sample_format() == out_type_set.sample_format() || out_type_set.sample_format() == LpcmStreamType::SampleFormat::kAny) { @@ -50,7 +49,7 @@ break; default: NOTREACHED() << "unsupported sample format " - << out_type_set.sample_format(); + << out_type_set.sample_format(); } } @@ -58,15 +57,14 @@ // Prefer not to mixdown/up. score += 10; } else { - return 0; // TODO(dalesat): Remove when we have mixdown/up. + return 0; // TODO(dalesat): Remove when we have mixdown/up. } - if (out_type_set.frames_per_second(). - contains(in_type.frames_per_second())) { + if (out_type_set.frames_per_second().contains(in_type.frames_per_second())) { // Very much prefer not to resample. score += 50; } else { - return 0; // TODO(dalesat): Remove when we have resamplers. + return 0; // TODO(dalesat): Remove when we have resamplers. } return score; @@ -150,7 +148,7 @@ // Need to decode. Create a decoder and go from there. std::shared_ptr<Decoder> decoder; Result result = Decoder::Create(in_type, &decoder); - if (result != Result::kOk) { + if (result != Result::kOk) { // No decoder found. *out_type = nullptr; return AddResult::kFailed; @@ -166,12 +164,11 @@ // (in_type) and the output lpcm stream type set for the type we need to convert // to (out_type_set). If the call succeeds, *out_type is set to the new output // type. Otherwise, *out_type is set to nullptr. -AddResult AddTransformsForLpcm( - const LpcmStreamType& in_type, - const LpcmStreamTypeSet& out_type_set, - Graph* graph, - OutputRef* output, - std::unique_ptr<StreamType>* out_type) { +AddResult AddTransformsForLpcm(const LpcmStreamType& in_type, + const LpcmStreamTypeSet& out_type_set, + Graph* graph, + OutputRef* output, + std::unique_ptr<StreamType>* out_type) { DCHECK(graph); DCHECK(out_type); @@ -179,9 +176,11 @@ // transforms that handle more than one conversion. if (in_type.sample_format() != out_type_set.sample_format() && out_type_set.sample_format() != LpcmStreamType::SampleFormat::kAny) { - *output = graph->ConnectOutputToPart( - *output, - graph->Add(LpcmReformatter::Create(in_type, out_type_set))).output(); + *output = + graph + ->ConnectOutputToPart(*output, graph->Add(LpcmReformatter::Create( + in_type, out_type_set))) + .output(); } if (!out_type_set.channels().contains(in_type.channels())) { @@ -200,11 +199,10 @@ // Build the resulting media type. *out_type = LpcmStreamType::Create( - out_type_set.sample_format() == LpcmStreamType::SampleFormat::kAny ? - in_type.sample_format() : - out_type_set.sample_format(), - in_type.channels(), - in_type.frames_per_second()); + out_type_set.sample_format() == LpcmStreamType::SampleFormat::kAny + ? in_type.sample_format() + : out_type_set.sample_format(), + in_type.channels(), in_type.frames_per_second()); return AddResult::kFinished; } @@ -239,15 +237,11 @@ *out_type = in_type.Clone(); return AddResult::kFinished; case StreamType::Scheme::kLpcm: - return AddTransformsForLpcm( - in_type, - *(*best)->lpcm(), - graph, - output, - out_type); + return AddTransformsForLpcm(in_type, *(*best)->lpcm(), graph, output, + out_type); default: NOTREACHED() << "FindBestLpcm produced unexpected type set scheme" - << (*best)->scheme(); + << (*best)->scheme(); return AddResult::kFailed; } } @@ -267,22 +261,13 @@ switch (in_type.scheme()) { case StreamType::Scheme::kLpcm: - return AddTransformsForLpcm( - *in_type.lpcm(), - out_type_sets, - graph, - output, - out_type); + return AddTransformsForLpcm(*in_type.lpcm(), out_type_sets, graph, output, + out_type); case StreamType::Scheme::kCompressedAudio: return AddTransformsForCompressedAudio( - *in_type.compressed_audio(), - out_type_sets, - graph, - output, - out_type); + *in_type.compressed_audio(), out_type_sets, graph, output, out_type); default: - NOTREACHED() << "conversion not supported for scheme" - << in_type.scheme(); + NOTREACHED() << "conversion not supported for scheme" << in_type.scheme(); *out_type = nullptr; return AddResult::kFailed; } @@ -304,12 +289,8 @@ const StreamType* type_to_convert = &in_type; std::unique_ptr<StreamType> converted_type; while (true) { - switch (AddTransforms( - *type_to_convert, - out_type_sets, - graph, - &out, - &converted_type)) { + switch (AddTransforms(*type_to_convert, out_type_sets, graph, &out, + &converted_type)) { case AddResult::kFailed: // Failed to find a suitable conversion. Return the pipeline to its // original state.
diff --git a/services/media/framework/conversion_pipeline_builder.h b/services/media/framework/conversion_pipeline_builder.h index 9f82f93..71c7cc3 100644 --- a/services/media/framework/conversion_pipeline_builder.h +++ b/services/media/framework/conversion_pipeline_builder.h
@@ -26,4 +26,4 @@ } // namespace media } // namespace mojo -#endif // SERVICES_MEDIA_FRAMEWORK_CONVERSION_PIPELINE_BUILDER_H_ +#endif // SERVICES_MEDIA_FRAMEWORK_CONVERSION_PIPELINE_BUILDER_H_
diff --git a/services/media/framework/engine.cc b/services/media/framework/engine.cc index 6421913..9035a88 100644 --- a/services/media/framework/engine.cc +++ b/services/media/framework/engine.cc
@@ -14,43 +14,34 @@ } void Engine::PrepareInput(const InputRef& input) { - VisitUpstream( - input, - [] (const InputRef& input, - const OutputRef& output, - const Stage::UpstreamCallback& callback) { - DCHECK(!input.actual().prepared()); - PayloadAllocator* allocator = input.stage_->PrepareInput(input.index_); - input.actual().set_prepared(true); - output.stage_->PrepareOutput(output.index_, allocator, callback); - }); + VisitUpstream(input, [](const InputRef& input, const OutputRef& output, + const Stage::UpstreamCallback& callback) { + DCHECK(!input.actual().prepared()); + PayloadAllocator* allocator = input.stage_->PrepareInput(input.index_); + input.actual().set_prepared(true); + output.stage_->PrepareOutput(output.index_, allocator, callback); + }); } void Engine::UnprepareInput(const InputRef& input) { - VisitUpstream( - input, - [] (const InputRef& input, - const OutputRef& output, - const Stage::UpstreamCallback& callback) { - DCHECK(input.actual().prepared()); - input.stage_->UnprepareInput(input.index_); - output.stage_->UnprepareOutput(output.index_, callback); - }); + VisitUpstream(input, [](const InputRef& input, const OutputRef& output, + const Stage::UpstreamCallback& callback) { + DCHECK(input.actual().prepared()); + input.stage_->UnprepareInput(input.index_); + output.stage_->UnprepareOutput(output.index_, callback); + }); } void Engine::FlushOutput(const OutputRef& output) { if (!output.connected()) { return; } - VisitDownstream( - output, - [] (const OutputRef& output, - const InputRef& input, - const Stage::DownstreamCallback& callback) { - DCHECK(input.actual().prepared()); - output.stage_->FlushOutput(output.index_); - input.stage_->FlushInput(input.index_, callback); - }); + VisitDownstream(output, [](const OutputRef& output, const InputRef& input, + const Stage::DownstreamCallback& callback) { + DCHECK(input.actual().prepared()); + output.stage_->FlushOutput(output.index_); + input.stage_->FlushInput(input.index_, callback); + }); } void Engine::RequestUpdate(Stage* stage) { @@ -81,9 +72,8 @@ } } -void Engine::VisitUpstream( - const InputRef& input, - const UpstreamVisitor& vistor) { +void Engine::VisitUpstream(const InputRef& input, + const UpstreamVisitor& vistor) { base::AutoLock lock(lock_); std::queue<InputRef> backlog; @@ -98,18 +88,14 @@ const OutputRef& output = input.mate(); Stage* output_stage = output.stage_; - vistor( - input, - output, - [output_stage, &backlog](size_t input_index) { - backlog.push(InputRef(output_stage, input_index)); - }); + vistor(input, output, [output_stage, &backlog](size_t input_index) { + backlog.push(InputRef(output_stage, input_index)); + }); } } -void Engine::VisitDownstream( - const OutputRef& output, - const DownstreamVisitor& vistor) { +void Engine::VisitDownstream(const OutputRef& output, + const DownstreamVisitor& vistor) { base::AutoLock lock(lock_); std::queue<OutputRef> backlog; @@ -124,12 +110,9 @@ const InputRef& input = output.mate(); Stage* input_stage = input.stage_; - vistor( - output, - input, - [input_stage, &backlog](size_t output_index) { - backlog.push(OutputRef(input_stage, output_index)); - }); + vistor(output, input, [input_stage, &backlog](size_t output_index) { + backlog.push(OutputRef(input_stage, output_index)); + }); } } @@ -153,7 +136,7 @@ } } -void Engine::Update(Stage *stage) { +void Engine::Update(Stage* stage) { lock_.AssertAcquired(); DCHECK(stage);
diff --git a/services/media/framework/engine.h b/services/media/framework/engine.h index aba8eb7..12fb35a 100644 --- a/services/media/framework/engine.h +++ b/services/media/framework/engine.h
@@ -107,28 +107,25 @@ void PushToDemandBacklog(Stage* stage); private: - using UpstreamVisitor = std::function<void( - const InputRef& input, - const OutputRef& output, - const Stage::UpstreamCallback& callback)>; - using DownstreamVisitor = std::function<void( - const OutputRef& output, - const InputRef& input, - const Stage::DownstreamCallback& callback)>; + using UpstreamVisitor = + std::function<void(const InputRef& input, + const OutputRef& output, + const Stage::UpstreamCallback& callback)>; + using DownstreamVisitor = + std::function<void(const OutputRef& output, + const InputRef& input, + const Stage::DownstreamCallback& callback)>; - void VisitUpstream( - const InputRef& input, - const UpstreamVisitor& vistor); + void VisitUpstream(const InputRef& input, const UpstreamVisitor& vistor); - void VisitDownstream( - const OutputRef& output, - const DownstreamVisitor& vistor); + void VisitDownstream(const OutputRef& output, + const DownstreamVisitor& vistor); // Processes the entire backlog. void Update(); // Performs processing for a single stage, updating the backlog accordingly. - void Update(Stage *stage); + void Update(Stage* stage); // Pops a stage from the supply backlog and returns it or returns nullptr if // the supply backlog is empty.
diff --git a/services/media/framework/formatting.cc b/services/media/framework/formatting.cc index 26c50bd..6dc293c 100644 --- a/services/media/framework/formatting.cc +++ b/services/media/framework/formatting.cc
@@ -64,9 +64,8 @@ return os; } -std::ostream& operator<<( - std::ostream& os, - const std::unique_ptr<StreamType>& value) { +std::ostream& operator<<(std::ostream& os, + const std::unique_ptr<StreamType>& value) { if (!value) { return os << "<nullptr>" << std::endl; } else { @@ -78,50 +77,53 @@ switch (value->scheme()) { case StreamType::Scheme::kMultiplexed: os << begl << "std::unique_ptr<StreamType> multiplex_type: " - << value->multiplexed()->multiplex_type(); + << value->multiplexed()->multiplex_type(); os << begl << "std::unique_ptr<std::vector<std::unique_ptr<StreamType>>>" - << " substream_types: " - << value->multiplexed()->substream_types(); + << " substream_types: " << value->multiplexed()->substream_types(); break; case StreamType::Scheme::kLpcm: - os << begl << "SampleFormat sample_format: " - << value->lpcm()->sample_format() << std::endl; - os << begl << "uint32_t channels: " - << value->lpcm()->channels() << std::endl; - os << begl << "uint32_t frames_per_second: " - << value->lpcm()->frames_per_second() << std::endl; + os << begl + << "SampleFormat sample_format: " << value->lpcm()->sample_format() + << std::endl; + os << begl << "uint32_t channels: " << value->lpcm()->channels() + << std::endl; + os << begl + << "uint32_t frames_per_second: " << value->lpcm()->frames_per_second() + << std::endl; break; case StreamType::Scheme::kCompressedAudio: - os << begl << "AudioEncoding encoding: " - << value->compressed_audio()->encoding() << std::endl; + os << begl + << "AudioEncoding encoding: " << value->compressed_audio()->encoding() + << std::endl; os << begl << "SampleFormat sample_format: " - << value->compressed_audio()->sample_format() << std::endl; - os << begl << "uint32_t channels: " - << value->compressed_audio()->channels() << std::endl; + << value->compressed_audio()->sample_format() << std::endl; + os << begl + << "uint32_t channels: " << value->compressed_audio()->channels() + << std::endl; os << begl << "uint32_t frames_per_second: " - << value->compressed_audio()->frames_per_second() << std::endl; + << value->compressed_audio()->frames_per_second() << std::endl; os << begl << "std::unique_ptr<Bytes> encoding_details: " - << value->compressed_audio()->encoding_details() << std::endl; + << value->compressed_audio()->encoding_details() << std::endl; break; case StreamType::Scheme::kVideo: - os << begl << "VideoEncoding encoding: " - << value->video()->encoding() << std::endl; - os << begl << "VideoProfile profile: " - << value->video()->profile() << std::endl; - os << begl << "PixelFormat pixel_format: " - << value->video()->pixel_format() << std::endl; - os << begl << "ColorSpace color_space: " - << value->video()->color_space() << std::endl; - os << begl << "uint32_t width: " - << value->video()->width() << std::endl; - os << begl << "uint32_t height: " - << value->video()->height() << std::endl; - os << begl << "uint32_t coded_width: " - << value->video()->coded_width() << std::endl; - os << begl << "uint32_t coded_height: " - << value->video()->coded_height() << std::endl; + os << begl << "VideoEncoding encoding: " << value->video()->encoding() + << std::endl; + os << begl << "VideoProfile profile: " << value->video()->profile() + << std::endl; + os << begl + << "PixelFormat pixel_format: " << value->video()->pixel_format() + << std::endl; + os << begl << "ColorSpace color_space: " << value->video()->color_space() + << std::endl; + os << begl << "uint32_t width: " << value->video()->width() << std::endl; + os << begl << "uint32_t height: " << value->video()->height() + << std::endl; + os << begl << "uint32_t coded_width: " << value->video()->coded_width() + << std::endl; + os << begl << "uint32_t coded_height: " << value->video()->coded_height() + << std::endl; os << begl << "std::unique_ptr<Bytes> encoding_details: " - << value->video()->encoding_details() << std::endl; + << value->video()->encoding_details() << std::endl; break; default: break; @@ -130,9 +132,8 @@ return os << outdent; } -std::ostream& operator<<( - std::ostream& os, - const std::unique_ptr<StreamTypeSet>& value) { +std::ostream& operator<<(std::ostream& os, + const std::unique_ptr<StreamTypeSet>& value) { if (!value) { return os << "<nullptr>" << std::endl; } else { @@ -144,36 +145,38 @@ switch (value->scheme()) { case StreamType::Scheme::kMultiplexed: os << begl << "std::unique_ptr<StreamTypeSet> multiplex_type_set: " - << value->multiplexed()->multiplex_type_set(); + << value->multiplexed()->multiplex_type_set(); os << begl << "std::unique_ptr<std::vector<std::unique_ptr<" - << "StreamTypeSet>>> substream_type_sets: " - << value->multiplexed()->substream_type_sets(); + << "StreamTypeSet>>> substream_type_sets: " + << value->multiplexed()->substream_type_sets(); break; case StreamType::Scheme::kLpcm: - os << begl << "SampleFormat sample_format: " - << value->lpcm()->sample_format() << std::endl; - os << begl << "Range<uint32_t> channels: " - << value->lpcm()->channels() << std::endl; + os << begl + << "SampleFormat sample_format: " << value->lpcm()->sample_format() + << std::endl; + os << begl << "Range<uint32_t> channels: " << value->lpcm()->channels() + << std::endl; os << begl << "Range<uint32_t> frames_per_second: " - << value->lpcm()->frames_per_second() << std::endl; + << value->lpcm()->frames_per_second() << std::endl; break; case StreamType::Scheme::kCompressedAudio: - os << begl << "AudioEncoding encoding: " - << value->compressed_audio()->encoding() << std::endl; + os << begl + << "AudioEncoding encoding: " << value->compressed_audio()->encoding() + << std::endl; os << begl << "SampleFormat sample_format: " - << value->compressed_audio()->sample_format() << std::endl; + << value->compressed_audio()->sample_format() << std::endl; os << begl << "Range<uint32_t> channels: " - << value->compressed_audio()->channels() << std::endl; + << value->compressed_audio()->channels() << std::endl; os << begl << "Range<uint32_t> frames_per_second: " - << value->compressed_audio()->frames_per_second() << std::endl; + << value->compressed_audio()->frames_per_second() << std::endl; break; case StreamType::Scheme::kVideo: - os << begl << "VideoEncoding encoding: " - << value->video()->encoding() << std::endl; - os << begl << "Range<uint32_t> width: " - << value->video()->width() << std::endl; - os << begl << "Range<uint32_t> height: " - << value->video()->height() << std::endl; + os << begl << "VideoEncoding encoding: " << value->video()->encoding() + << std::endl; + os << begl << "Range<uint32_t> width: " << value->video()->width() + << std::endl; + os << begl << "Range<uint32_t> height: " << value->video()->height() + << std::endl; break; default: break; @@ -270,9 +273,8 @@ return os; } -std::ostream& operator<<( - std::ostream& os, - CompressedAudioStreamType::AudioEncoding value) { +std::ostream& operator<<(std::ostream& os, + CompressedAudioStreamType::AudioEncoding value) { switch (value) { case CompressedAudioStreamType::AudioEncoding::kUnknown: return os << "kUnknown"; @@ -284,9 +286,8 @@ return os; } -std::ostream& operator<<( - std::ostream& os, - VideoStreamType::VideoEncoding value) { +std::ostream& operator<<(std::ostream& os, + VideoStreamType::VideoEncoding value) { switch (value) { case VideoStreamType::VideoEncoding::kUnknown: return os << "kUnknown"; @@ -300,9 +301,8 @@ return os; } -std::ostream& operator<<( - std::ostream& os, - VideoStreamType::VideoProfile value) { +std::ostream& operator<<(std::ostream& os, + VideoStreamType::VideoProfile value) { switch (value) { case VideoStreamType::VideoProfile::kUnknown: return os << "kUnknown"; @@ -388,9 +388,8 @@ return os; } -std::ostream& operator<<( - std::ostream& os, - const std::unique_ptr<Bytes>& value) { +std::ostream& operator<<(std::ostream& os, + const std::unique_ptr<Bytes>& value) { if (value == nullptr) { return os << "<nullptr>"; } else { @@ -403,10 +402,10 @@ return os << "true"; } else if (value.max) { return os << "false..true"; - } else { + } else { return os << "false"; } } -} // namespace media -} // namespace mojo +} // namespace media +} // namespace mojo
diff --git a/services/media/framework/formatting.h b/services/media/framework/formatting.h index 2cdbc62..b01919d 100644 --- a/services/media/framework/formatting.h +++ b/services/media/framework/formatting.h
@@ -52,18 +52,16 @@ std::ostream& operator<<(std::ostream& os, const PacketPtr& value); std::ostream& operator<<(std::ostream& os, StreamType::Scheme value); std::ostream& operator<<(std::ostream& os, LpcmStreamType::SampleFormat value); -std::ostream& operator<<( - std::ostream& os, - CompressedAudioStreamType::AudioEncoding value); -std::ostream& operator<<( - std::ostream& os, - VideoStreamType::VideoEncoding value); +std::ostream& operator<<(std::ostream& os, + CompressedAudioStreamType::AudioEncoding value); +std::ostream& operator<<(std::ostream& os, + VideoStreamType::VideoEncoding value); std::ostream& operator<<(std::ostream& os, VideoStreamType::VideoProfile value); std::ostream& operator<<(std::ostream& os, VideoStreamType::PixelFormat value); std::ostream& operator<<(std::ostream& os, VideoStreamType::ColorSpace value); std::ostream& operator<<(std::ostream& os, const std::unique_ptr<Bytes>& value); -template<typename T> +template <typename T> std::ostream& operator<<(std::ostream& os, Range<T> value) { return os << value.min << ".." << value.max; } @@ -72,12 +70,10 @@ // The following overloads add newlines. -std::ostream& operator<<( - std::ostream& os, - const std::unique_ptr<StreamType>& value); -std::ostream& operator<<( - std::ostream& os, - const std::unique_ptr<StreamTypeSet>& value); +std::ostream& operator<<(std::ostream& os, + const std::unique_ptr<StreamType>& value); +std::ostream& operator<<(std::ostream& os, + const std::unique_ptr<StreamTypeSet>& value); std::ostream& operator<<( std::ostream& os, const std::unique_ptr<std::vector<std::unique_ptr<StreamType>>>& value); @@ -85,7 +81,7 @@ std::ostream& os, const std::unique_ptr<std::vector<std::unique_ptr<StreamTypeSet>>>& value); -} // namespace media -} // namespace mojo +} // namespace media +} // namespace mojo -#endif // SERVICES_MEDIA_FRAMEWORK_FORMATTING_H_ +#endif // SERVICES_MEDIA_FRAMEWORK_FORMATTING_H_
diff --git a/services/media/framework/graph.cc b/services/media/framework/graph.cc index cc47a03..7bd1d4c 100644 --- a/services/media/framework/graph.cc +++ b/services/media/framework/graph.cc
@@ -8,9 +8,7 @@ namespace media { Graph::Graph() { - update_function_ = [this](Stage* stage) { - engine_.RequestUpdate(stage); - }; + update_function_ = [this](Stage* stage) { engine_.RequestUpdate(stage); }; } Graph::~Graph() { @@ -62,27 +60,23 @@ return input.part(); } -PartRef Graph::ConnectParts( - PartRef upstream_part, - PartRef downstream_part) { +PartRef Graph::ConnectParts(PartRef upstream_part, PartRef downstream_part) { DCHECK(upstream_part.valid()); DCHECK(downstream_part.valid()); Connect(upstream_part.output(), downstream_part.input()); return downstream_part; } -PartRef Graph::ConnectOutputToPart( - const OutputRef& output, - PartRef downstream_part) { +PartRef Graph::ConnectOutputToPart(const OutputRef& output, + PartRef downstream_part) { DCHECK(output.valid()); DCHECK(downstream_part.valid()); Connect(output, downstream_part.input()); return downstream_part; } -PartRef Graph::ConnectPartToInput( - PartRef upstream_part, - const InputRef& input) { +PartRef Graph::ConnectPartToInput(PartRef upstream_part, + const InputRef& input) { DCHECK(upstream_part.valid()); DCHECK(input.valid()); Connect(upstream_part.output(), input); @@ -128,7 +122,7 @@ void Graph::RemovePartsConnectedToPart(PartRef part) { DCHECK(part.valid()); - std::deque<PartRef> to_remove { part }; + std::deque<PartRef> to_remove{part}; while (!to_remove.empty()) { PartRef part = to_remove.front();
diff --git a/services/media/framework/graph.h b/services/media/framework/graph.h index ea833f0..f0b6482 100644 --- a/services/media/framework/graph.h +++ b/services/media/framework/graph.h
@@ -23,17 +23,18 @@ // StageCreator::Create creates a stage for a part. DEFINE_STAGE_CREATOR defines // a specialization for a particular model/stage type pair. Every new // model/stage type pair that's defined will need an entry here. -template<typename T, typename Enable = void> class StageCreator; +template <typename T, typename Enable = void> +class StageCreator; -#define DEFINE_STAGE_CREATOR(TModel, TStage) \ -template<typename T> \ -class StageCreator<T, typename std::enable_if< \ - std::is_base_of<TModel, T>::value>::type> { \ - public: \ - static inline Stage* Create(std::shared_ptr<T> t_ptr) { \ - return new TStage(std::shared_ptr<TModel>(t_ptr)); \ - } \ -}; +#define DEFINE_STAGE_CREATOR(TModel, TStage) \ + template <typename T> \ + class StageCreator< \ + T, typename std::enable_if<std::is_base_of<TModel, T>::value>::type> { \ + public: \ + static inline Stage* Create(std::shared_ptr<T> t_ptr) { \ + return new TStage(std::shared_ptr<TModel>(t_ptr)); \ + } \ + }; DEFINE_STAGE_CREATOR(MultistreamSource, MultistreamSourceStage); DEFINE_STAGE_CREATOR(Transform, TransformStage); @@ -42,7 +43,7 @@ #undef DEFINE_STAGE_CREATOR -} // namespace +} // namespace // // USAGE @@ -119,7 +120,7 @@ ~Graph(); // Adds a part to the graph. - template<typename T> + template <typename T> PartRef Add(std::shared_ptr<T> t_ptr) { DCHECK(t_ptr); return Add(StageCreator<T>::Create(t_ptr)); @@ -164,7 +165,7 @@ // Adds all the parts in t (which must all have one input and one output) and // connects them in sequence to the output connector. Returns the output // connector of the last part or the output parameter if it is empty. - template<typename T> + template <typename T> OutputRef AddAndConnectAll(OutputRef output, const T& t) { for (const auto& element : t) { PartRef part = Add(StageCreator<T>::Create(element));
diff --git a/services/media/framework/lpcm_util.cc b/services/media/framework/lpcm_util.cc index 3b92781..bc94ce2 100644 --- a/services/media/framework/lpcm_util.cc +++ b/services/media/framework/lpcm_util.cc
@@ -10,7 +10,7 @@ namespace media { // LpcmUtil implementation that processes samples of type T. -template<typename T> +template <typename T> class LpcmUtilImpl : public LpcmUtil { public: ~LpcmUtilImpl(); @@ -21,11 +21,10 @@ void Mix(const void* in, void* out, size_t frame_count) const override; - void Interleave( - const void* in, - size_t in_byte_count, - void* out, - size_t frame_count) const override; + void Interleave(const void* in, + size_t in_byte_count, + void* out, + size_t frame_count) const override; private: LpcmUtilImpl(const LpcmStreamType& stream_type); @@ -52,8 +51,8 @@ result = new LpcmUtilImpl<float>(stream_type); break; default: - NOTREACHED() - << "unsupported sample format " << stream_type.sample_format(); + NOTREACHED() << "unsupported sample format " + << stream_type.sample_format(); result = nullptr; break; } @@ -61,70 +60,65 @@ return std::unique_ptr<LpcmUtil>(result); } -template<typename T> -LpcmUtilImpl<T>::LpcmUtilImpl(const LpcmStreamType& stream_type) : - stream_type_(stream_type) {} +template <typename T> +LpcmUtilImpl<T>::LpcmUtilImpl(const LpcmStreamType& stream_type) + : stream_type_(stream_type) {} -template<typename T> +template <typename T> LpcmUtilImpl<T>::~LpcmUtilImpl() {} -template<typename T> +template <typename T> void LpcmUtilImpl<T>::Silence(void* buffer, size_t frame_count) const { T* sample = reinterpret_cast<T*>(buffer); - for ( - size_t sample_countdown = frame_count * stream_type_.channels(); - sample_countdown != 0; - --sample_countdown) { + for (size_t sample_countdown = frame_count * stream_type_.channels(); + sample_countdown != 0; --sample_countdown) { *sample = 0; sample++; } } -template<> +template <> void LpcmUtilImpl<uint8_t>::Silence(void* buffer, size_t frame_count) const { std::memset(buffer, 0x80, frame_count * stream_type_.bytes_per_frame()); } -template<> +template <> void LpcmUtilImpl<int16_t>::Silence(void* buffer, size_t frame_count) const { std::memset(buffer, 0, frame_count * stream_type_.bytes_per_frame()); } -template<> +template <> void LpcmUtilImpl<int32_t>::Silence(void* buffer, size_t frame_count) const { std::memset(buffer, 0, frame_count * stream_type_.bytes_per_frame()); } -template<typename T> -void LpcmUtilImpl<T>::Copy(const void* in, void* out, size_t frame_count) - const { +template <typename T> +void LpcmUtilImpl<T>::Copy(const void* in, + void* out, + size_t frame_count) const { std::memcpy(out, in, stream_type_.min_buffer_size(frame_count)); } -template<typename T> -void LpcmUtilImpl<T>::Mix(const void* in, void* out, size_t frame_count) - const { +template <typename T> +void LpcmUtilImpl<T>::Mix(const void* in, void* out, size_t frame_count) const { const T* in_sample = reinterpret_cast<const T*>(in); T* out_sample = reinterpret_cast<T*>(out); - for ( - size_t sample_countdown = frame_count * stream_type_.channels(); - sample_countdown != 0; - --sample_countdown) { - *out_sample += *in_sample; // TODO(dalesat): Limit. + for (size_t sample_countdown = frame_count * stream_type_.channels(); + sample_countdown != 0; --sample_countdown) { + *out_sample += *in_sample; // TODO(dalesat): Limit. out_sample++; in_sample++; } } -template<> -void LpcmUtilImpl<uint8_t>::Mix(const void* in, void* out, size_t frame_count) - const { +template <> +void LpcmUtilImpl<uint8_t>::Mix(const void* in, + void* out, + size_t frame_count) const { const uint8_t* in_sample = reinterpret_cast<const uint8_t*>(in); uint8_t* out_sample = reinterpret_cast<uint8_t*>(out); - for ( - size_t sample_countdown = frame_count * stream_type_.channels(); - sample_countdown != 0; - --sample_countdown) { + for (size_t sample_countdown = frame_count * stream_type_.channels(); + sample_countdown != 0; --sample_countdown) { *out_sample = uint8_t(uint16_t(*out_sample) + uint16_t(*in_sample) - 0x80); // TODO(dalesat): Limit. out_sample++; @@ -132,12 +126,11 @@ } } -template<typename T> -void LpcmUtilImpl<T>::Interleave( - const void* in, - size_t in_byte_count, - void* out, - size_t frame_count) const { +template <typename T> +void LpcmUtilImpl<T>::Interleave(const void* in, + size_t in_byte_count, + void* out, + size_t frame_count) const { DCHECK(in); DCHECK(in_byte_count); DCHECK(out);
diff --git a/services/media/framework/lpcm_util.h b/services/media/framework/lpcm_util.h index 888cfc8..bdaeab3 100644 --- a/services/media/framework/lpcm_util.h +++ b/services/media/framework/lpcm_util.h
@@ -33,14 +33,13 @@ // channel buffer per channel. The samples for each channel are contiguous // in the respective channel buffer with possible empty space at the end // (hence the in_type_count and the frame_count). - virtual void Interleave( - const void* in, - size_t in_byte_count, - void* out, - size_t frame_count) const = 0; + virtual void Interleave(const void* in, + size_t in_byte_count, + void* out, + size_t frame_count) const = 0; }; } // namespace media } // namespace mojo -#endif // SERVICES_MEDIA_FRAMEWORK_LPCM_UTIL_H_ +#endif // SERVICES_MEDIA_FRAMEWORK_LPCM_UTIL_H_
diff --git a/services/media/framework/metadata.cc b/services/media/framework/metadata.cc index bd39df8..ff31cc4 100644 --- a/services/media/framework/metadata.cc +++ b/services/media/framework/metadata.cc
@@ -8,39 +8,31 @@ namespace media { // static -std::unique_ptr<Metadata> Metadata::Create( - uint64_t duration_ns, - const std::string& title, - const std::string& artist, - const std::string& album, - const std::string& publisher, - const std::string& genre, - const std::string& composer) { +std::unique_ptr<Metadata> Metadata::Create(uint64_t duration_ns, + const std::string& title, + const std::string& artist, + const std::string& album, + const std::string& publisher, + const std::string& genre, + const std::string& composer) { return std::unique_ptr<Metadata>(new Metadata( - duration_ns, - title, - artist, - album, - publisher, - genre, - composer)); + duration_ns, title, artist, album, publisher, genre, composer)); } -Metadata::Metadata( - uint64_t duration_ns, - const std::string& title, - const std::string& artist, - const std::string& album, - const std::string& publisher, - const std::string& genre, - const std::string& composer) : - duration_ns_(duration_ns), - title_(title), - artist_(artist), - album_(album), - publisher_(publisher), - genre_(genre), - composer_(composer) {} +Metadata::Metadata(uint64_t duration_ns, + const std::string& title, + const std::string& artist, + const std::string& album, + const std::string& publisher, + const std::string& genre, + const std::string& composer) + : duration_ns_(duration_ns), + title_(title), + artist_(artist), + album_(album), + publisher_(publisher), + genre_(genre), + composer_(composer) {} Metadata::~Metadata() {}
diff --git a/services/media/framework/metadata.h b/services/media/framework/metadata.h index 2d46358..37633a2 100644 --- a/services/media/framework/metadata.h +++ b/services/media/framework/metadata.h
@@ -20,14 +20,13 @@ // TODO(dalesat): Probably needs to be extensible. Consider using map-like. class Metadata { public: - static std::unique_ptr<Metadata> Create( - uint64_t duration_ns, - const std::string& title, - const std::string& artist, - const std::string& album, - const std::string& publisher, - const std::string& genre, - const std::string& composer); + static std::unique_ptr<Metadata> Create(uint64_t duration_ns, + const std::string& title, + const std::string& artist, + const std::string& album, + const std::string& publisher, + const std::string& genre, + const std::string& composer); ~Metadata(); @@ -46,25 +45,18 @@ const std::string& composer() const { return composer_; } std::unique_ptr<Metadata> Clone() const { - return Create( - duration_ns_, - title_, - artist_, - album_, - publisher_, - genre_, - composer_); + return Create(duration_ns_, title_, artist_, album_, publisher_, genre_, + composer_); } private: - Metadata( - uint64_t duration_ns, - const std::string& title, - const std::string& artist, - const std::string& album, - const std::string& publisher, - const std::string& genre, - const std::string& composer); + Metadata(uint64_t duration_ns, + const std::string& title, + const std::string& artist, + const std::string& album, + const std::string& publisher, + const std::string& genre, + const std::string& composer); uint64_t duration_ns_; std::string title_; @@ -80,4 +72,4 @@ } // namespace media } // namespace mojo -#endif // SERVICES_MEDIA_FRAMEWORK_METADATA_H_ +#endif // SERVICES_MEDIA_FRAMEWORK_METADATA_H_
diff --git a/services/media/framework/models/active_multistream_sink.h b/services/media/framework/models/active_multistream_sink.h index 2246fe4..9347fc9 100644 --- a/services/media/framework/models/active_multistream_sink.h +++ b/services/media/framework/models/active_multistream_sink.h
@@ -46,4 +46,4 @@ } // namespace media } // namespace mojo -#endif // MOJO_MEDIA_MODELS_ACTIVE_MULTISTREAM_SINK_H_ +#endif // MOJO_MEDIA_MODELS_ACTIVE_MULTISTREAM_SINK_H_
diff --git a/services/media/framework/models/active_sink.h b/services/media/framework/models/active_sink.h index e0aa70f..3463dfc 100644 --- a/services/media/framework/models/active_sink.h +++ b/services/media/framework/models/active_sink.h
@@ -34,4 +34,4 @@ } // namespace media } // namespace mojo -#endif // MOJO_MEDIA_MODELS_ACTIVE_SINK_H_ +#endif // MOJO_MEDIA_MODELS_ACTIVE_SINK_H_
diff --git a/services/media/framework/models/active_source.h b/services/media/framework/models/active_source.h index e286279..0e3f67f 100644 --- a/services/media/framework/models/active_source.h +++ b/services/media/framework/models/active_source.h
@@ -36,4 +36,4 @@ } // namespace media } // namespace mojo -#endif // MOJO_MEDIA_MODELS_ACTIVE_SOURCE_H_ +#endif // MOJO_MEDIA_MODELS_ACTIVE_SOURCE_H_
diff --git a/services/media/framework/models/demand.h b/services/media/framework/models/demand.h index 843923d..9487a43 100644 --- a/services/media/framework/models/demand.h +++ b/services/media/framework/models/demand.h
@@ -25,4 +25,4 @@ } // namespace media } // namespace mojo -#endif // MOJO_MEDIA_MODELS_DEMAND_H_ +#endif // MOJO_MEDIA_MODELS_DEMAND_H_
diff --git a/services/media/framework/models/multistream_source.h b/services/media/framework/models/multistream_source.h index 01a82e9..0782353 100644 --- a/services/media/framework/models/multistream_source.h +++ b/services/media/framework/models/multistream_source.h
@@ -23,10 +23,10 @@ // Gets a packet for the stream indicated via stream_index_out. This call // should always produce a packet until end-of-stream. The caller is // responsible for releasing the packet. - virtual PacketPtr PullPacket(size_t *stream_index_out) = 0; + virtual PacketPtr PullPacket(size_t* stream_index_out) = 0; }; } // namespace media } // namespace mojo -#endif // MOJO_MEDIA_MODELS_MULTISTREAM_SOURCE_H_ +#endif // MOJO_MEDIA_MODELS_MULTISTREAM_SOURCE_H_
diff --git a/services/media/framework/models/transform.h b/services/media/framework/models/transform.h index 0a17d32..495aae5 100644 --- a/services/media/framework/models/transform.h +++ b/services/media/framework/models/transform.h
@@ -22,14 +22,13 @@ // packet should be processed again. new_input indicates whether the input // packet is new (true) or is being processed again (false). An output packet // may or may not be generated for any given invocation of this method. - virtual bool TransformPacket( - const PacketPtr& input, - bool new_input, - PayloadAllocator* allocator, - PacketPtr* output) = 0; + virtual bool TransformPacket(const PacketPtr& input, + bool new_input, + PayloadAllocator* allocator, + PacketPtr* output) = 0; }; } // namespace media } // namespace mojo -#endif // MOJO_MEDIA_MODELS_TRANSFORM_H_ +#endif // MOJO_MEDIA_MODELS_TRANSFORM_H_
diff --git a/services/media/framework/packet.cc b/services/media/framework/packet.cc index e6b9155..eef3e3e 100644 --- a/services/media/framework/packet.cc +++ b/services/media/framework/packet.cc
@@ -9,31 +9,22 @@ namespace mojo { namespace media { -Packet::Packet( - int64_t pts, - bool end_of_stream, - size_t size, - void* payload) : - pts_(pts), - end_of_stream_(end_of_stream), - size_(size), - payload_(payload) { +Packet::Packet(int64_t pts, bool end_of_stream, size_t size, void* payload) + : pts_(pts), end_of_stream_(end_of_stream), size_(size), payload_(payload) { DCHECK((size == 0) == (payload == nullptr)); } class PacketImpl : public Packet { public: - PacketImpl( - int64_t pts, - bool end_of_stream, - size_t size, - void* payload, - PayloadAllocator* allocator) : - Packet(pts, end_of_stream, size, payload), - allocator_(allocator) {} + PacketImpl(int64_t pts, + bool end_of_stream, + size_t size, + void* payload, + PayloadAllocator* allocator) + : Packet(pts, end_of_stream, size, payload), allocator_(allocator) {} protected: - ~PacketImpl() override {}; + ~PacketImpl() override{}; void Release() override { // In the default implementation, payload() will be nullptr if and only if @@ -51,43 +42,31 @@ }; // static -PacketPtr Packet::Create( - int64_t pts, - bool end_of_stream, - size_t size, - void* payload, - PayloadAllocator* allocator) { +PacketPtr Packet::Create(int64_t pts, + bool end_of_stream, + size_t size, + void* payload, + PayloadAllocator* allocator) { DCHECK(payload == nullptr || allocator != nullptr); - return PacketPtr(new PacketImpl( - pts, - end_of_stream, - size, - payload, - allocator)); + return PacketPtr( + new PacketImpl(pts, end_of_stream, size, payload, allocator)); } // static -PacketPtr Packet::CreateNoAllocator( - int64_t pts, - bool end_of_stream, - size_t size, - void* payload) { - return PacketPtr(new PacketImpl( - pts, - end_of_stream, - size, - payload, - nullptr)); +PacketPtr Packet::CreateNoAllocator(int64_t pts, + bool end_of_stream, + size_t size, + void* payload) { + return PacketPtr(new PacketImpl(pts, end_of_stream, size, payload, nullptr)); } // static PacketPtr Packet::CreateEndOfStream(int64_t pts) { - return PacketPtr(new PacketImpl( - pts, - true, // end_of_stream - 0, // size - nullptr, // payload - nullptr)); // allocator + return PacketPtr(new PacketImpl(pts, + true, // end_of_stream + 0, // size + nullptr, // payload + nullptr)); // allocator } } // namespace media
diff --git a/services/media/framework/packet.h b/services/media/framework/packet.h index 952383c..6ab1259 100644 --- a/services/media/framework/packet.h +++ b/services/media/framework/packet.h
@@ -36,21 +36,19 @@ // Creates a packet. If size is 0, payload must be nullptr and vice-versa. // If payload is not nullptr, an allocator must be provided. - static PacketPtr Create( - int64_t pts, - bool end_of_stream, - size_t size, - void* payload, - PayloadAllocator* allocator); + static PacketPtr Create(int64_t pts, + bool end_of_stream, + size_t size, + void* payload, + PayloadAllocator* allocator); // Creates a packet. If size is 0, payload must be nullptr and vice-versa. // No allocator is provided, and the payload will not be released when the // packet is released. - static PacketPtr CreateNoAllocator( - int64_t pts, - bool end_of_stream, - size_t size, - void* payload); + static PacketPtr CreateNoAllocator(int64_t pts, + bool end_of_stream, + size_t size, + void* payload); // Creates an end-of-stream packet with no payload. static PacketPtr CreateEndOfStream(int64_t pts); @@ -64,11 +62,7 @@ void* payload() const { return payload_; } protected: - Packet( - int64_t pts, - bool end_of_stream, - size_t size, - void* payload); + Packet(int64_t pts, bool end_of_stream, size_t size, void* payload); virtual ~Packet() {} @@ -91,4 +85,4 @@ } // namespace media } // namespace mojo -#endif // SERVICES_MEDIA_FRAMEWORK_PACKET_H_ +#endif // SERVICES_MEDIA_FRAMEWORK_PACKET_H_
diff --git a/services/media/framework/parts/decoder.h b/services/media/framework/parts/decoder.h index ed9e1e0..447fd0e 100644 --- a/services/media/framework/parts/decoder.h +++ b/services/media/framework/parts/decoder.h
@@ -18,9 +18,8 @@ class Decoder : public Transform { public: // Creates a Decoder object for a given stream type. - static Result Create( - const StreamType& stream_type, - std::shared_ptr<Decoder>* decoder_out); + static Result Create(const StreamType& stream_type, + std::shared_ptr<Decoder>* decoder_out); ~Decoder() override {} @@ -31,4 +30,4 @@ } // namespace media } // namespace mojo -#endif // SERVICES_MEDIA_FRAMEWORK_PARTS_DECODER_H_ +#endif // SERVICES_MEDIA_FRAMEWORK_PARTS_DECODER_H_
diff --git a/services/media/framework/parts/demux.h b/services/media/framework/parts/demux.h index d5a4cce..d9aa468 100644 --- a/services/media/framework/parts/demux.h +++ b/services/media/framework/parts/demux.h
@@ -35,9 +35,8 @@ }; // Creates a Demux object for a given reader. - static Result Create( - std::shared_ptr<Reader> reader, - std::shared_ptr<Demux>* demux_out); + static Result Create(std::shared_ptr<Reader> reader, + std::shared_ptr<Demux>* demux_out); ~Demux() override {} @@ -65,4 +64,4 @@ } // namespace media } // namespace mojo -#endif // SERVICES_MEDIA_FRAMEWORK_PARTS_DEMUX_H_ +#endif // SERVICES_MEDIA_FRAMEWORK_PARTS_DEMUX_H_
diff --git a/services/media/framework/parts/file_reader.cc b/services/media/framework/parts/file_reader.cc index 4061ecd..39cdc8d 100644 --- a/services/media/framework/parts/file_reader.cc +++ b/services/media/framework/parts/file_reader.cc
@@ -67,5 +67,5 @@ return true; } -} // namespace media -} // namespace mojo +} // namespace media +} // namespace mojo
diff --git a/services/media/framework/parts/file_reader.h b/services/media/framework/parts/file_reader.h index c25291c..c62d504 100644 --- a/services/media/framework/parts/file_reader.h +++ b/services/media/framework/parts/file_reader.h
@@ -42,4 +42,4 @@ } // namespace media } // namespace mojo -#endif // SERVICES_MEDIA_FRAMEWORK_PARTS_FILE_READER_H_ +#endif // SERVICES_MEDIA_FRAMEWORK_PARTS_FILE_READER_H_
diff --git a/services/media/framework/parts/lpcm_reformatter.cc b/services/media/framework/parts/lpcm_reformatter.cc index 79b5458..51ac33d 100644 --- a/services/media/framework/parts/lpcm_reformatter.cc +++ b/services/media/framework/parts/lpcm_reformatter.cc
@@ -10,21 +10,19 @@ // LpcmReformatter implementation that accepts samples of type TIn and // produces samples of type TOut. -template<typename TIn, typename TOut> +template <typename TIn, typename TOut> class LpcmReformatterImpl : public LpcmReformatter { public: - LpcmReformatterImpl( - const LpcmStreamType& in_type, - const LpcmStreamTypeSet& out_type); + LpcmReformatterImpl(const LpcmStreamType& in_type, + const LpcmStreamTypeSet& out_type); ~LpcmReformatterImpl() override; // Transform implementation. - bool TransformPacket( - const PacketPtr& input, - bool new_input, - PayloadAllocator* allocator, - PacketPtr* output) override; + bool TransformPacket(const PacketPtr& input, + bool new_input, + PayloadAllocator* allocator, + PacketPtr* output) override; private: LpcmStreamType in_type_; @@ -41,20 +39,16 @@ switch (out_type.sample_format()) { case LpcmStreamType::SampleFormat::kUnsigned8: case LpcmStreamType::SampleFormat::kAny: - result = new LpcmReformatterImpl<uint8_t, uint8_t>( - in_type, out_type); + result = new LpcmReformatterImpl<uint8_t, uint8_t>(in_type, out_type); break; case LpcmStreamType::SampleFormat::kSigned16: - result = new LpcmReformatterImpl<uint8_t, int16_t>( - in_type, out_type); + result = new LpcmReformatterImpl<uint8_t, int16_t>(in_type, out_type); break; case LpcmStreamType::SampleFormat::kSigned24In32: - result = new LpcmReformatterImpl<uint8_t, int32_t>( - in_type, out_type); + result = new LpcmReformatterImpl<uint8_t, int32_t>(in_type, out_type); break; case LpcmStreamType::SampleFormat::kFloat: - result = new LpcmReformatterImpl<uint8_t, float>( - in_type, out_type); + result = new LpcmReformatterImpl<uint8_t, float>(in_type, out_type); break; default: NOTREACHED() << "unsupported sample format"; @@ -65,21 +59,17 @@ case LpcmStreamType::SampleFormat::kSigned16: switch (out_type.sample_format()) { case LpcmStreamType::SampleFormat::kUnsigned8: - result = new LpcmReformatterImpl<int16_t, uint8_t>( - in_type, out_type); + result = new LpcmReformatterImpl<int16_t, uint8_t>(in_type, out_type); break; case LpcmStreamType::SampleFormat::kSigned16: case LpcmStreamType::SampleFormat::kAny: - result = new LpcmReformatterImpl<int16_t, int16_t>( - in_type, out_type); + result = new LpcmReformatterImpl<int16_t, int16_t>(in_type, out_type); break; case LpcmStreamType::SampleFormat::kSigned24In32: - result = new LpcmReformatterImpl<int16_t, int32_t>( - in_type, out_type); + result = new LpcmReformatterImpl<int16_t, int32_t>(in_type, out_type); break; case LpcmStreamType::SampleFormat::kFloat: - result = new LpcmReformatterImpl<int16_t, float>( - in_type, out_type); + result = new LpcmReformatterImpl<int16_t, float>(in_type, out_type); break; default: NOTREACHED() << "unsupported sample format"; @@ -90,21 +80,17 @@ case LpcmStreamType::SampleFormat::kSigned24In32: switch (out_type.sample_format()) { case LpcmStreamType::SampleFormat::kUnsigned8: - result = new LpcmReformatterImpl<int32_t, uint8_t>( - in_type, out_type); + result = new LpcmReformatterImpl<int32_t, uint8_t>(in_type, out_type); break; case LpcmStreamType::SampleFormat::kSigned16: - result = new LpcmReformatterImpl<int32_t, int16_t>( - in_type, out_type); + result = new LpcmReformatterImpl<int32_t, int16_t>(in_type, out_type); break; case LpcmStreamType::SampleFormat::kSigned24In32: case LpcmStreamType::SampleFormat::kAny: - result = new LpcmReformatterImpl<int32_t, int32_t>( - in_type, out_type); + result = new LpcmReformatterImpl<int32_t, int32_t>(in_type, out_type); break; case LpcmStreamType::SampleFormat::kFloat: - result = new LpcmReformatterImpl<int32_t, float>( - in_type, out_type); + result = new LpcmReformatterImpl<int32_t, float>(in_type, out_type); break; default: NOTREACHED() << "unsupported sample format"; @@ -115,16 +101,13 @@ case LpcmStreamType::SampleFormat::kFloat: switch (out_type.sample_format()) { case LpcmStreamType::SampleFormat::kUnsigned8: - result = new LpcmReformatterImpl<float, uint8_t>( - in_type, out_type); + result = new LpcmReformatterImpl<float, uint8_t>(in_type, out_type); break; case LpcmStreamType::SampleFormat::kSigned16: - result = new LpcmReformatterImpl<float, int16_t>( - in_type, out_type); + result = new LpcmReformatterImpl<float, int16_t>(in_type, out_type); break; case LpcmStreamType::SampleFormat::kSigned24In32: - result = new LpcmReformatterImpl<float, int32_t>( - in_type, out_type); + result = new LpcmReformatterImpl<float, int32_t>(in_type, out_type); break; case LpcmStreamType::SampleFormat::kFloat: case LpcmStreamType::SampleFormat::kAny: @@ -145,19 +128,18 @@ return std::shared_ptr<LpcmReformatter>(result); } -template<typename TIn, typename TOut> +template <typename TIn, typename TOut> LpcmReformatterImpl<TIn, TOut>::LpcmReformatterImpl( const LpcmStreamType& in_type, - const LpcmStreamTypeSet& out_type) : - in_type_(in_type), - out_type_( - out_type.sample_format() == LpcmStreamType::SampleFormat::kAny ? - in_type.sample_format() : - out_type.sample_format(), - in_type.channels(), - in_type.frames_per_second()) {} + const LpcmStreamTypeSet& out_type) + : in_type_(in_type), + out_type_(out_type.sample_format() == LpcmStreamType::SampleFormat::kAny + ? in_type.sample_format() + : out_type.sample_format(), + in_type.channels(), + in_type.frames_per_second()) {} -template<typename TIn, typename TOut> +template <typename TIn, typename TOut> LpcmReformatterImpl<TIn, TOut>::~LpcmReformatterImpl() {} namespace { @@ -180,7 +162,7 @@ return Clamp(val, 1 << 23, -(1 << 23)); } -template<typename TIn, typename TOut> +template <typename TIn, typename TOut> inline void CopySample(TOut* dest, const TIn* source) { *dest = static_cast<TOut>(*source); } @@ -233,9 +215,9 @@ *dest = static_cast<float>(Clamp(*source)) / 0x800000; } -} // namespace +} // namespace -template<typename TIn, typename TOut> +template <typename TIn, typename TOut> bool LpcmReformatterImpl<TIn, TOut>::TransformPacket( const PacketPtr& input, bool new_input, @@ -248,12 +230,8 @@ uint64_t in_size = input->size(); if (in_size == 0) { // Zero-sized input packet. Make a copy. - *output = Packet::Create( - input->pts(), - input->end_of_stream(), - 0, - nullptr, - nullptr); + *output = Packet::Create(input->pts(), input->end_of_stream(), 0, nullptr, + nullptr); return true; } @@ -283,12 +261,8 @@ ++out_channel; } - *output = Packet::Create( - input->pts(), - input->end_of_stream(), - out_size, - buffer, - allocator); + *output = Packet::Create(input->pts(), input->end_of_stream(), out_size, + buffer, allocator); return true; }
diff --git a/services/media/framework/parts/lpcm_reformatter.h b/services/media/framework/parts/lpcm_reformatter.h index 06b6ab6..eabf837 100644 --- a/services/media/framework/parts/lpcm_reformatter.h +++ b/services/media/framework/parts/lpcm_reformatter.h
@@ -23,4 +23,4 @@ } // namespace media } // namespace mojo -#endif // SERVICES_MEDIA_FRAMEWORK_PARTS_LPCM_REFORMATTER_H_ +#endif // SERVICES_MEDIA_FRAMEWORK_PARTS_LPCM_REFORMATTER_H_
diff --git a/services/media/framework/parts/null_sink.cc b/services/media/framework/parts/null_sink.cc index c805d50..701ba1e 100644 --- a/services/media/framework/parts/null_sink.cc +++ b/services/media/framework/parts/null_sink.cc
@@ -23,5 +23,5 @@ return Demand::kNeutral; } -} // namespace media -} // namespace mojo +} // namespace media +} // namespace mojo
diff --git a/services/media/framework/parts/null_sink.h b/services/media/framework/parts/null_sink.h index d30caaa..3bd39ed 100644 --- a/services/media/framework/parts/null_sink.h +++ b/services/media/framework/parts/null_sink.h
@@ -14,7 +14,7 @@ class NullSink : public ActiveSink { public: static std::shared_ptr<NullSink> Create() { - return std::shared_ptr<NullSink>(new NullSink()); + return std::shared_ptr<NullSink>(new NullSink()); } ~NullSink() override;
diff --git a/services/media/framework/parts/reader.cc b/services/media/framework/parts/reader.cc index d1d992e..e546258 100644 --- a/services/media/framework/parts/reader.cc +++ b/services/media/framework/parts/reader.cc
@@ -33,5 +33,5 @@ return result; } -} // namespace media -} // namespace mojo +} // namespace media +} // namespace mojo
diff --git a/services/media/framework/parts/reader.h b/services/media/framework/parts/reader.h index faa7dd4..c5bf16f 100644 --- a/services/media/framework/parts/reader.h +++ b/services/media/framework/parts/reader.h
@@ -51,4 +51,4 @@ } // namespace media } // namespace mojo -#endif // MOJO_SERVICES_MEDIA_READER_H_ +#endif // MOJO_SERVICES_MEDIA_READER_H_
diff --git a/services/media/framework/payload_allocator.cc b/services/media/framework/payload_allocator.cc index 94938f7..3687100 100644 --- a/services/media/framework/payload_allocator.cc +++ b/services/media/framework/payload_allocator.cc
@@ -35,12 +35,12 @@ static constexpr DefaultAllocator default_allocator; -} // namespace +} // namespace // static PayloadAllocator* PayloadAllocator::GetDefault() { return const_cast<DefaultAllocator*>(&default_allocator); } -} // namespace media -} // namespace mojo +} // namespace media +} // namespace mojo
diff --git a/services/media/framework/payload_allocator.h b/services/media/framework/payload_allocator.h index c5ca645..8e398f3 100644 --- a/services/media/framework/payload_allocator.h +++ b/services/media/framework/payload_allocator.h
@@ -27,4 +27,4 @@ } // namespace media } // namespace mojo -#endif // SERVICES_MEDIA_FRAMEWORK_PAYLOAD_ALLOCATOR_H_ +#endif // SERVICES_MEDIA_FRAMEWORK_PAYLOAD_ALLOCATOR_H_
diff --git a/services/media/framework/refs.cc b/services/media/framework/refs.cc index c2670a2..bcff5cb 100644 --- a/services/media/framework/refs.cc +++ b/services/media/framework/refs.cc
@@ -55,8 +55,7 @@ return actual().mate(); } -InputRef::InputRef(Stage* stage, size_t index) : - stage_(stage), index_(index) { +InputRef::InputRef(Stage* stage, size_t index) : stage_(stage), index_(index) { DCHECK(valid()); } @@ -79,8 +78,8 @@ return actual().mate(); } -OutputRef::OutputRef(Stage* stage, size_t index) : - stage_(stage), index_(index) { +OutputRef::OutputRef(Stage* stage, size_t index) + : stage_(stage), index_(index) { DCHECK(valid()); }
diff --git a/services/media/framework/result.h b/services/media/framework/result.h index ae6fc6d..48e75e3 100644 --- a/services/media/framework/result.h +++ b/services/media/framework/result.h
@@ -23,4 +23,4 @@ } // namespace media } // namespace mojo -#endif // SERVICES_MEDIA_FRAMEWORK_RESULT_H_ +#endif // SERVICES_MEDIA_FRAMEWORK_RESULT_H_
diff --git a/services/media/framework/safe_clone.h b/services/media/framework/safe_clone.h index 1e4546f..31b47c6 100644 --- a/services/media/framework/safe_clone.h +++ b/services/media/framework/safe_clone.h
@@ -11,12 +11,12 @@ namespace mojo { namespace media { -template<typename T> +template <typename T> std::unique_ptr<T> SafeClone(const std::unique_ptr<T>& t_ptr) { return t_ptr ? t_ptr.get()->Clone() : nullptr; } -template<typename T> +template <typename T> std::unique_ptr<std::vector<std::unique_ptr<T>>> SafeClone( const std::unique_ptr<std::vector<std::unique_ptr<T>>>& vec) { if (vec == nullptr) { @@ -37,4 +37,4 @@ } // namespace media } // namespace mojo -#endif // SERVICES_MEDIA_FRAMEWORK_SAFE_CLONE_H_ +#endif // SERVICES_MEDIA_FRAMEWORK_SAFE_CLONE_H_
diff --git a/services/media/framework/stages/active_multistream_sink_stage.cc b/services/media/framework/stages/active_multistream_sink_stage.cc index fa7cbde..ec4b12e 100644 --- a/services/media/framework/stages/active_multistream_sink_stage.cc +++ b/services/media/framework/stages/active_multistream_sink_stage.cc
@@ -8,7 +8,8 @@ namespace media { ActiveMultistreamSinkStage::ActiveMultistreamSinkStage( - std::shared_ptr<ActiveMultistreamSink> sink) : sink_(sink) { + std::shared_ptr<ActiveMultistreamSink> sink) + : sink_(sink) { DCHECK(sink_); sink_->SetHost(this); // Add one unallocated input so this stage isn't misidentified as a source. @@ -56,13 +57,12 @@ base::AutoLock lock(lock_); - for (auto iter = pending_inputs_.begin(); iter != pending_inputs_.end(); ) { + for (auto iter = pending_inputs_.begin(); iter != pending_inputs_.end();) { DCHECK(*iter < inputs_.size()); StageInput* input = inputs_[*iter].get(); if (input->input_.packet_from_upstream()) { input->demand_ = sink_->SupplyPacket( - input->index_, - std::move(input->input_.packet_from_upstream())); + input->index_, std::move(input->input_.packet_from_upstream())); if (input->demand_ == Demand::kNegative) { auto remove_iter = iter; @@ -141,9 +141,8 @@ return inputs_.size(); } -void ActiveMultistreamSinkStage::UpdateDemand( - size_t input_index, - Demand demand) { +void ActiveMultistreamSinkStage::UpdateDemand(size_t input_index, + Demand demand) { lock_.Acquire(); DCHECK(input_index < inputs_.size()); DCHECK(demand != Demand::kNegative);
diff --git a/services/media/framework/stages/active_multistream_sink_stage.h b/services/media/framework/stages/active_multistream_sink_stage.h index 526b7de..dc4ee28 100644 --- a/services/media/framework/stages/active_multistream_sink_stage.h +++ b/services/media/framework/stages/active_multistream_sink_stage.h
@@ -17,9 +17,8 @@ namespace media { // A stage that hosts an ActiveSink. -class ActiveMultistreamSinkStage : - public Stage, - public ActiveMultistreamSinkHost { +class ActiveMultistreamSinkStage : public Stage, + public ActiveMultistreamSinkHost { public: ActiveMultistreamSinkStage(std::shared_ptr<ActiveMultistreamSink> sink); @@ -36,16 +35,13 @@ PayloadAllocator* PrepareInput(size_t index) override; - void PrepareOutput( - size_t index, - PayloadAllocator* allocator, - const UpstreamCallback& callback) override; + void PrepareOutput(size_t index, + PayloadAllocator* allocator, + const UpstreamCallback& callback) override; void Update(Engine* engine) override; - void FlushInput( - size_t index, - const DownstreamCallback& callback) override; + void FlushInput(size_t index, const DownstreamCallback& callback) override; void FlushOutput(size_t index) override; @@ -58,10 +54,8 @@ private: struct StageInput { - StageInput(size_t index) : - index_(index), - allocated_(false), - demand_(Demand::kNegative) {} + StageInput(size_t index) + : index_(index), allocated_(false), demand_(Demand::kNegative) {} Input input_; size_t index_; bool allocated_;
diff --git a/services/media/framework/stages/active_sink_stage.cc b/services/media/framework/stages/active_sink_stage.cc index a4d41eb..7c1d90a 100644 --- a/services/media/framework/stages/active_sink_stage.cc +++ b/services/media/framework/stages/active_sink_stage.cc
@@ -7,8 +7,8 @@ namespace mojo { namespace media { -ActiveSinkStage::ActiveSinkStage(std::shared_ptr<ActiveSink> sink) : - sink_(sink) { +ActiveSinkStage::ActiveSinkStage(std::shared_ptr<ActiveSink> sink) + : sink_(sink) { DCHECK(sink_); demand_function_ = [this](Demand demand) { @@ -46,10 +46,9 @@ return sink_->allocator(); } -void ActiveSinkStage::PrepareOutput( - size_t index, - PayloadAllocator* allocator, - const UpstreamCallback& callback) { +void ActiveSinkStage::PrepareOutput(size_t index, + PayloadAllocator* allocator, + const UpstreamCallback& callback) { CHECK(false) << "PrepareOutput called on sink"; } @@ -65,9 +64,8 @@ input_.SetDemand(sink_demand_, engine); } -void ActiveSinkStage::FlushInput( - size_t index, - const DownstreamCallback& callback) { +void ActiveSinkStage::FlushInput(size_t index, + const DownstreamCallback& callback) { DCHECK(sink_); input_.Flush(); sink_->Flush();
diff --git a/services/media/framework/stages/active_sink_stage.h b/services/media/framework/stages/active_sink_stage.h index 796238d..928d619 100644 --- a/services/media/framework/stages/active_sink_stage.h +++ b/services/media/framework/stages/active_sink_stage.h
@@ -31,16 +31,13 @@ PayloadAllocator* PrepareInput(size_t index) override; - void PrepareOutput( - size_t index, - PayloadAllocator* allocator, - const UpstreamCallback& callback) override; + void PrepareOutput(size_t index, + PayloadAllocator* allocator, + const UpstreamCallback& callback) override; void Update(Engine* engine) override; - void FlushInput( - size_t index, - const DownstreamCallback& callback) override; + void FlushInput(size_t index, const DownstreamCallback& callback) override; void FlushOutput(size_t index) override;
diff --git a/services/media/framework/stages/active_source_stage.cc b/services/media/framework/stages/active_source_stage.cc index 190b42c..1ae91b8 100644 --- a/services/media/framework/stages/active_source_stage.cc +++ b/services/media/framework/stages/active_source_stage.cc
@@ -7,9 +7,8 @@ namespace mojo { namespace media { -ActiveSourceStage::ActiveSourceStage(std::shared_ptr<ActiveSource> source) : - source_(source), - prepared_(false) { +ActiveSourceStage::ActiveSourceStage(std::shared_ptr<ActiveSource> source) + : source_(source), prepared_(false) { DCHECK(source_); supply_function_ = [this](PacketPtr packet) { @@ -48,19 +47,18 @@ return nullptr; } -void ActiveSourceStage::PrepareOutput( - size_t index, - PayloadAllocator* allocator, - const UpstreamCallback& callback) { +void ActiveSourceStage::PrepareOutput(size_t index, + PayloadAllocator* allocator, + const UpstreamCallback& callback) { DCHECK_EQ(index, 0u); DCHECK(source_); if (source_->can_accept_allocator()) { // Give the source the provided allocator or the default if non was // provided. - source_->set_allocator( - allocator == nullptr ? PayloadAllocator::GetDefault() : allocator); - } else if (allocator){ + source_->set_allocator(allocator == nullptr ? PayloadAllocator::GetDefault() + : allocator); + } else if (allocator) { // The source can't use the provided allocator, so the output must copy // packets. output_.SetCopyAllocator(allocator); @@ -69,9 +67,8 @@ prepared_ = true; } -void ActiveSourceStage::UnprepareOutput( - size_t index, - const UpstreamCallback& callback) { +void ActiveSourceStage::UnprepareOutput(size_t index, + const UpstreamCallback& callback) { DCHECK_EQ(index, 0u); DCHECK(source_); @@ -92,9 +89,8 @@ } } -void ActiveSourceStage::FlushInput( - size_t index, - const DownstreamCallback& callback) { +void ActiveSourceStage::FlushInput(size_t index, + const DownstreamCallback& callback) { CHECK(false) << "FlushInput called on source"; }
diff --git a/services/media/framework/stages/active_source_stage.h b/services/media/framework/stages/active_source_stage.h index 1714be1..37e95b9 100644 --- a/services/media/framework/stages/active_source_stage.h +++ b/services/media/framework/stages/active_source_stage.h
@@ -31,20 +31,15 @@ PayloadAllocator* PrepareInput(size_t index) override; - void PrepareOutput( - size_t index, - PayloadAllocator* allocator, - const UpstreamCallback& callback) override; + void PrepareOutput(size_t index, + PayloadAllocator* allocator, + const UpstreamCallback& callback) override; - void UnprepareOutput( - size_t index, - const UpstreamCallback& callback) override; + void UnprepareOutput(size_t index, const UpstreamCallback& callback) override; void Update(Engine* engine) override; - void FlushInput( - size_t index, - const DownstreamCallback& callback) override; + void FlushInput(size_t index, const DownstreamCallback& callback) override; void FlushOutput(size_t index) override;
diff --git a/services/media/framework/stages/multistream_source_stage.cc b/services/media/framework/stages/multistream_source_stage.cc index 3d64ba0..65f687f 100644 --- a/services/media/framework/stages/multistream_source_stage.cc +++ b/services/media/framework/stages/multistream_source_stage.cc
@@ -8,9 +8,8 @@ namespace media { MultistreamSourceStage::MultistreamSourceStage( - std::shared_ptr<MultistreamSource> source) : - source_(source), - ended_streams_(0) { + std::shared_ptr<MultistreamSource> source) + : source_(source), ended_streams_(0) { DCHECK(source); outputs_.resize(source->stream_count()); } @@ -40,10 +39,9 @@ return nullptr; } -void MultistreamSourceStage::PrepareOutput( - size_t index, - PayloadAllocator* allocator, - const UpstreamCallback& callback) { +void MultistreamSourceStage::PrepareOutput(size_t index, + PayloadAllocator* allocator, + const UpstreamCallback& callback) { DCHECK(index < outputs_.size()); if (allocator != nullptr) { @@ -54,9 +52,8 @@ } } -void MultistreamSourceStage::UnprepareOutput( - size_t index, - const UpstreamCallback& callback) { +void MultistreamSourceStage::UnprepareOutput(size_t index, + const UpstreamCallback& callback) { DCHECK(index < outputs_.size()); outputs_[index].SetCopyAllocator(nullptr); } @@ -104,9 +101,8 @@ } } -void MultistreamSourceStage::FlushInput( - size_t index, - const DownstreamCallback& callback) { +void MultistreamSourceStage::FlushInput(size_t index, + const DownstreamCallback& callback) { CHECK(false) << "FlushInput called on source"; }
diff --git a/services/media/framework/stages/multistream_source_stage.h b/services/media/framework/stages/multistream_source_stage.h index d7af7a2..d3b2aea 100644 --- a/services/media/framework/stages/multistream_source_stage.h +++ b/services/media/framework/stages/multistream_source_stage.h
@@ -32,20 +32,15 @@ PayloadAllocator* PrepareInput(size_t index) override; - void PrepareOutput( - size_t index, - PayloadAllocator* allocator, - const UpstreamCallback& callback) override; + void PrepareOutput(size_t index, + PayloadAllocator* allocator, + const UpstreamCallback& callback) override; - void UnprepareOutput( - size_t index, - const UpstreamCallback& callback) override; + void UnprepareOutput(size_t index, const UpstreamCallback& callback) override; void Update(Engine* engine) override; - void FlushInput( - size_t index, - const DownstreamCallback& callback) override; + void FlushInput(size_t index, const DownstreamCallback& callback) override; void FlushOutput(size_t index) override;
diff --git a/services/media/framework/stages/output.cc b/services/media/framework/stages/output.cc index 1180cf8..d3198af 100644 --- a/services/media/framework/stages/output.cc +++ b/services/media/framework/stages/output.cc
@@ -9,9 +9,7 @@ namespace mojo { namespace media { -Output::Output() : - demand_(Demand::kNegative), - copy_allocator_(nullptr) {} +Output::Output() : demand_(Demand::kNegative), copy_allocator_(nullptr) {} Output::~Output() {} @@ -51,7 +49,7 @@ if (copy_allocator_ != nullptr) { // Need to copy the packet due to an allocation conflict. size_t size = packet->size(); - void *buffer; + void* buffer; if (size == 0) { buffer = nullptr; @@ -64,12 +62,8 @@ memcpy(buffer, packet->payload(), size); } - packet = Packet::Create( - packet->pts(), - packet->end_of_stream(), - size, - buffer, - copy_allocator_); + packet = Packet::Create(packet->pts(), packet->end_of_stream(), size, + buffer, copy_allocator_); } if (actual_mate().SupplyPacketFromOutput(std::move(packet))) {
diff --git a/services/media/framework/stages/stage.cc b/services/media/framework/stages/stage.cc index 211469c..44e925f 100644 --- a/services/media/framework/stages/stage.cc +++ b/services/media/framework/stages/stage.cc
@@ -8,17 +8,13 @@ namespace mojo { namespace media { -Stage::Stage() : - in_supply_backlog_(false), - in_demand_backlog_(false) {} +Stage::Stage() : in_supply_backlog_(false), in_demand_backlog_(false) {} Stage::~Stage() {} void Stage::UnprepareInput(size_t index) {} -void Stage::UnprepareOutput( - size_t index, - const UpstreamCallback& callback) {} +void Stage::UnprepareOutput(size_t index, const UpstreamCallback& callback) {} } // namespace media } // namespace mojo
diff --git a/services/media/framework/stages/stage.h b/services/media/framework/stages/stage.h index 6e43d00..491c3e9 100644 --- a/services/media/framework/stages/stage.h +++ b/services/media/framework/stages/stage.h
@@ -53,10 +53,9 @@ // by the output or nullptr if there is no such requirement. The callback is // used to indicate what inputs are ready to be prepared as a consequence of // preparing the output. - virtual void PrepareOutput( - size_t index, - PayloadAllocator* allocator, - const UpstreamCallback& callback) = 0; + virtual void PrepareOutput(size_t index, + PayloadAllocator* allocator, + const UpstreamCallback& callback) = 0; // Unprepares the input. The default implementation does nothing. virtual void UnprepareInput(size_t index); @@ -64,18 +63,14 @@ // Unprepares the output. The default implementation does nothing. The // the callback is used to indicate what inputs are ready to be unprepared as // a consequence of unpreparing the output. - virtual void UnprepareOutput( - size_t index, - const UpstreamCallback& callback); + virtual void UnprepareOutput(size_t index, const UpstreamCallback& callback); // Performs processing. virtual void Update(Engine* engine) = 0; // Flushes an input. The callback is used to indicate what outputs are ready // to be flushed as a consequence of flushing the input. - virtual void FlushInput( - size_t index, - const DownstreamCallback& callback) = 0; + virtual void FlushInput(size_t index, const DownstreamCallback& callback) = 0; // Flushes an output. virtual void FlushOutput(size_t index) = 0;
diff --git a/services/media/framework/stages/transform_stage.cc b/services/media/framework/stages/transform_stage.cc index dce8254..cca753c 100644 --- a/services/media/framework/stages/transform_stage.cc +++ b/services/media/framework/stages/transform_stage.cc
@@ -7,11 +7,8 @@ namespace mojo { namespace media { -TransformStage::TransformStage( - std::shared_ptr<Transform> transform) : - transform_(transform), - allocator_(nullptr), - input_packet_is_new_(true) { +TransformStage::TransformStage(std::shared_ptr<Transform> transform) + : transform_(transform), allocator_(nullptr), input_packet_is_new_(true) { DCHECK(transform_); } @@ -40,10 +37,9 @@ return nullptr; } -void TransformStage::PrepareOutput( - size_t index, - PayloadAllocator* allocator, - const UpstreamCallback& callback) { +void TransformStage::PrepareOutput(size_t index, + PayloadAllocator* allocator, + const UpstreamCallback& callback) { DCHECK_EQ(index, 0u); allocator_ = @@ -52,9 +48,8 @@ callback(0); } -void TransformStage::UnprepareOutput( - size_t index, - const UpstreamCallback& callback) { +void TransformStage::UnprepareOutput(size_t index, + const UpstreamCallback& callback) { allocator_ = nullptr; callback(0); } @@ -65,11 +60,9 @@ if (input_.packet_from_upstream() && output_.demand() != Demand::kNegative) { PacketPtr output_packet; - if (transform_->TransformPacket( - input_.packet_from_upstream(), - input_packet_is_new_, - allocator_, - &output_packet)) { + if (transform_->TransformPacket(input_.packet_from_upstream(), + input_packet_is_new_, allocator_, + &output_packet)) { input_.packet_from_upstream().reset(); input_packet_is_new_ = true; } else { @@ -84,9 +77,8 @@ input_.SetDemand(output_.demand(), engine); } -void TransformStage::FlushInput( - size_t index, - const DownstreamCallback& callback) { +void TransformStage::FlushInput(size_t index, + const DownstreamCallback& callback) { DCHECK_EQ(index, 0u); input_.Flush(); callback(0);
diff --git a/services/media/framework/stages/transform_stage.h b/services/media/framework/stages/transform_stage.h index 07cec4a..f9f8543 100644 --- a/services/media/framework/stages/transform_stage.h +++ b/services/media/framework/stages/transform_stage.h
@@ -29,20 +29,15 @@ PayloadAllocator* PrepareInput(size_t index) override; - void PrepareOutput( - size_t index, - PayloadAllocator* allocator, - const UpstreamCallback& callback) override; + void PrepareOutput(size_t index, + PayloadAllocator* allocator, + const UpstreamCallback& callback) override; - void UnprepareOutput( - size_t index, - const UpstreamCallback& callback) override; + void UnprepareOutput(size_t index, const UpstreamCallback& callback) override; void Update(Engine* engine) override; - void FlushInput( - size_t index, - const DownstreamCallback& callback) override; + void FlushInput(size_t index, const DownstreamCallback& callback) override; void FlushOutput(size_t index) override;
diff --git a/services/media/framework/stream_type.cc b/services/media/framework/stream_type.cc index ae2f19a..0fad313 100644 --- a/services/media/framework/stream_type.cc +++ b/services/media/framework/stream_type.cc
@@ -75,10 +75,10 @@ MultiplexedStreamType::MultiplexedStreamType( std::unique_ptr<StreamType> multiplex_type, - std::unique_ptr<std::vector<std::unique_ptr<StreamType>>> substream_types) : - StreamType(Scheme::kMultiplexed), - multiplex_type_(std::move(multiplex_type)), - substream_types_(std::move(substream_types)) {} + std::unique_ptr<std::vector<std::unique_ptr<StreamType>>> substream_types) + : StreamType(Scheme::kMultiplexed), + multiplex_type_(std::move(multiplex_type)), + substream_types_(std::move(substream_types)) {} MultiplexedStreamType::~MultiplexedStreamType() {} @@ -93,10 +93,10 @@ MultiplexedStreamTypeSet::MultiplexedStreamTypeSet( std::unique_ptr<StreamTypeSet> multiplex_type_set, std::unique_ptr<std::vector<std::unique_ptr<StreamTypeSet>>> - substream_type_sets) : - StreamTypeSet(StreamType::Scheme::kMultiplexed), - multiplex_type_set_(std::move(multiplex_type_set)), - substream_type_sets_(std::move(substream_type_sets)) {} + substream_type_sets) + : StreamTypeSet(StreamType::Scheme::kMultiplexed), + multiplex_type_set_(std::move(multiplex_type_set)), + substream_type_sets_(std::move(substream_type_sets)) {} MultiplexedStreamTypeSet::~MultiplexedStreamTypeSet() {} @@ -105,31 +105,27 @@ } std::unique_ptr<StreamTypeSet> MultiplexedStreamTypeSet::Clone() const { - return Create( - SafeClone(multiplex_type_set()), - SafeClone(substream_type_sets())); + return Create(SafeClone(multiplex_type_set()), + SafeClone(substream_type_sets())); } -LpcmStreamType::LpcmStreamType( - SampleFormat sample_format, - uint32_t channels, - uint32_t frames_per_second) : - LpcmStreamType( - Scheme::kLpcm, - sample_format, - channels, - frames_per_second) {} +LpcmStreamType::LpcmStreamType(SampleFormat sample_format, + uint32_t channels, + uint32_t frames_per_second) + : LpcmStreamType(Scheme::kLpcm, + sample_format, + channels, + frames_per_second) {} -LpcmStreamType::LpcmStreamType( - Scheme scheme, - SampleFormat sample_format, - uint32_t channels, - uint32_t frames_per_second) : - StreamType(scheme), - sample_format_(sample_format), - channels_(channels), - frames_per_second_(frames_per_second), - sample_size_(SampleSizeFromFormat(sample_format)) {} +LpcmStreamType::LpcmStreamType(Scheme scheme, + SampleFormat sample_format, + uint32_t channels, + uint32_t frames_per_second) + : StreamType(scheme), + sample_format_(sample_format), + channels_(channels), + frames_per_second_(frames_per_second), + sample_size_(SampleSizeFromFormat(sample_format)) {} LpcmStreamType::~LpcmStreamType() {} @@ -138,9 +134,8 @@ } // static -uint32_t LpcmStreamType::SampleSizeFromFormat( - SampleFormat sample_format) { - switch(sample_format) { +uint32_t LpcmStreamType::SampleSizeFromFormat(SampleFormat sample_format) { + switch (sample_format) { case SampleFormat::kUnsigned8: return sizeof(uint8_t); case SampleFormat::kSigned16: @@ -161,25 +156,22 @@ return Create(sample_format(), channels(), frames_per_second()); } -LpcmStreamTypeSet::LpcmStreamTypeSet( - LpcmStreamType::SampleFormat sample_format, - Range<uint32_t> channels, - Range<uint32_t> frames_per_second) : - LpcmStreamTypeSet( - StreamType::Scheme::kLpcm, - sample_format, - channels, - frames_per_second) {} +LpcmStreamTypeSet::LpcmStreamTypeSet(LpcmStreamType::SampleFormat sample_format, + Range<uint32_t> channels, + Range<uint32_t> frames_per_second) + : LpcmStreamTypeSet(StreamType::Scheme::kLpcm, + sample_format, + channels, + frames_per_second) {} -LpcmStreamTypeSet::LpcmStreamTypeSet( - StreamType::Scheme scheme, - LpcmStreamType::SampleFormat sample_format, - Range<uint32_t> channels, - Range<uint32_t> frames_per_second) : - StreamTypeSet(scheme), - sample_format_(sample_format), - channels_(channels), - frames_per_second_(frames_per_second) {} +LpcmStreamTypeSet::LpcmStreamTypeSet(StreamType::Scheme scheme, + LpcmStreamType::SampleFormat sample_format, + Range<uint32_t> channels, + Range<uint32_t> frames_per_second) + : StreamTypeSet(scheme), + sample_format_(sample_format), + channels_(channels), + frames_per_second_(frames_per_second) {} LpcmStreamTypeSet::~LpcmStreamTypeSet() {} @@ -188,11 +180,10 @@ } bool LpcmStreamTypeSet::contains(const LpcmStreamType& type) const { - return - (sample_format() == type.sample_format() || + return (sample_format() == type.sample_format() || sample_format() == LpcmStreamType::SampleFormat::kAny) && - channels().contains(type.frames_per_second()) && - frames_per_second().contains(type.frames_per_second()); + channels().contains(type.frames_per_second()) && + frames_per_second().contains(type.frames_per_second()); } std::unique_ptr<StreamTypeSet> LpcmStreamTypeSet::Clone() const { @@ -200,18 +191,17 @@ } CompressedAudioStreamType::CompressedAudioStreamType( - AudioEncoding encoding, - SampleFormat sample_format, - uint32_t channels, - uint32_t frames_per_second, - std::unique_ptr<Bytes> encoding_details) : - LpcmStreamType( - Scheme::kCompressedAudio, - sample_format, - channels, - frames_per_second), - encoding_(encoding), - encoding_details_(std::move(encoding_details)) {} + AudioEncoding encoding, + SampleFormat sample_format, + uint32_t channels, + uint32_t frames_per_second, + std::unique_ptr<Bytes> encoding_details) + : LpcmStreamType(Scheme::kCompressedAudio, + sample_format, + channels, + frames_per_second), + encoding_(encoding), + encoding_details_(std::move(encoding_details)) {} CompressedAudioStreamType::~CompressedAudioStreamType() {} @@ -221,72 +211,61 @@ } std::unique_ptr<StreamType> CompressedAudioStreamType::Clone() const { - return Create( - encoding(), - sample_format(), - channels(), - frames_per_second(), - SafeClone(encoding_details())); + return Create(encoding(), sample_format(), channels(), frames_per_second(), + SafeClone(encoding_details())); } CompressedAudioStreamTypeSet::CompressedAudioStreamTypeSet( - CompressedAudioStreamType::AudioEncoding encoding, - CompressedAudioStreamType::SampleFormat sample_format, - Range<uint32_t> channels, - Range<uint32_t> frames_per_second) : - LpcmStreamTypeSet( - StreamType::Scheme::kCompressedAudio, - sample_format, - channels, - frames_per_second), - encoding_(encoding) {} + CompressedAudioStreamType::AudioEncoding encoding, + CompressedAudioStreamType::SampleFormat sample_format, + Range<uint32_t> channels, + Range<uint32_t> frames_per_second) + : LpcmStreamTypeSet(StreamType::Scheme::kCompressedAudio, + sample_format, + channels, + frames_per_second), + encoding_(encoding) {} CompressedAudioStreamTypeSet::~CompressedAudioStreamTypeSet() {} const CompressedAudioStreamTypeSet* - CompressedAudioStreamTypeSet::compressed_audio() const { +CompressedAudioStreamTypeSet::compressed_audio() const { return this; } bool CompressedAudioStreamTypeSet::contains( const CompressedAudioStreamType& type) const { - return - (encoding() == type.encoding() || + return (encoding() == type.encoding() || encoding() == CompressedAudioStreamType::AudioEncoding::kAny) && - (sample_format() == type.sample_format() || + (sample_format() == type.sample_format() || sample_format() == LpcmStreamType::SampleFormat::kAny) && - channels().contains(type.frames_per_second()) && - frames_per_second().contains(type.frames_per_second()); + channels().contains(type.frames_per_second()) && + frames_per_second().contains(type.frames_per_second()); } std::unique_ptr<StreamTypeSet> CompressedAudioStreamTypeSet::Clone() const { - return Create( - encoding(), - sample_format(), - channels(), - frames_per_second()); + return Create(encoding(), sample_format(), channels(), frames_per_second()); } -VideoStreamType::VideoStreamType( - VideoEncoding encoding, - VideoProfile profile, - PixelFormat pixel_format, - ColorSpace color_space, - uint32_t width, - uint32_t height, - uint32_t coded_width, - uint32_t coded_height, - std::unique_ptr<Bytes> encoding_details) : - StreamType(StreamType::Scheme::kVideo), - encoding_(encoding), - profile_(profile), - pixel_format_(pixel_format), - color_space_(color_space), - width_(width), - height_(height), - coded_width_(coded_width), - coded_height_(coded_height), - encoding_details_(std::move(encoding_details)) {} +VideoStreamType::VideoStreamType(VideoEncoding encoding, + VideoProfile profile, + PixelFormat pixel_format, + ColorSpace color_space, + uint32_t width, + uint32_t height, + uint32_t coded_width, + uint32_t coded_height, + std::unique_ptr<Bytes> encoding_details) + : StreamType(StreamType::Scheme::kVideo), + encoding_(encoding), + profile_(profile), + pixel_format_(pixel_format), + color_space_(color_space), + width_(width), + height_(height), + coded_width_(coded_width), + coded_height_(coded_height), + encoding_details_(std::move(encoding_details)) {} VideoStreamType::~VideoStreamType() {} @@ -295,26 +274,18 @@ } std::unique_ptr<StreamType> VideoStreamType::Clone() const { - return Create( - encoding(), - profile(), - pixel_format(), - color_space(), - width(), - height(), - coded_width(), - coded_height(), - SafeClone(encoding_details())); + return Create(encoding(), profile(), pixel_format(), color_space(), width(), + height(), coded_width(), coded_height(), + SafeClone(encoding_details())); } -VideoStreamTypeSet::VideoStreamTypeSet( - VideoStreamType::VideoEncoding encoding, - Range<uint32_t> width, - Range<uint32_t> height) : - StreamTypeSet(StreamType::Scheme::kVideo), - encoding_(encoding), - width_(width), - height_(height) {} +VideoStreamTypeSet::VideoStreamTypeSet(VideoStreamType::VideoEncoding encoding, + Range<uint32_t> width, + Range<uint32_t> height) + : StreamTypeSet(StreamType::Scheme::kVideo), + encoding_(encoding), + width_(width), + height_(height) {} VideoStreamTypeSet::~VideoStreamTypeSet() {} @@ -323,11 +294,8 @@ } std::unique_ptr<StreamTypeSet> VideoStreamTypeSet::Clone() const { - return Create( - encoding(), - width(), - height()); + return Create(encoding(), width(), height()); } -} // namespace media -} // namespace mojo +} // namespace media +} // namespace mojo
diff --git a/services/media/framework/stream_type.h b/services/media/framework/stream_type.h index 31021e2..82a61e8 100644 --- a/services/media/framework/stream_type.h +++ b/services/media/framework/stream_type.h
@@ -81,9 +81,7 @@ virtual ~StreamType(); - Scheme scheme() const { - return scheme_; - } + Scheme scheme() const { return scheme_; } virtual const MultiplexedStreamType* multiplexed() const; virtual const LpcmStreamType* lpcm() const; @@ -96,7 +94,7 @@ Scheme scheme_; }; -template<typename T> +template <typename T> struct Range { Range(T min_param, T max_param) : min(min_param), max(max_param) { DCHECK(min_param <= max_param); @@ -105,9 +103,7 @@ T min; T max; - constexpr bool contains(const T& t) const { - return t >= min && t <= max; - } + constexpr bool contains(const T& t) const { return t >= min && t <= max; } }; class StreamTypeSet; @@ -127,9 +123,7 @@ virtual ~StreamTypeSet(); - StreamType::Scheme scheme() const { - return scheme_; - } + StreamType::Scheme scheme() const { return scheme_; } virtual const MultiplexedStreamTypeSet* multiplexed() const; virtual const LpcmStreamTypeSet* lpcm() const; @@ -149,10 +143,8 @@ std::unique_ptr<StreamType> multiplex_type, std::unique_ptr<std::vector<std::unique_ptr<StreamType>>> substream_types) { - return std::unique_ptr<StreamType>( - new MultiplexedStreamType( - std::move(multiplex_type), - std::move(substream_types))); + return std::unique_ptr<StreamType>(new MultiplexedStreamType( + std::move(multiplex_type), std::move(substream_types))); } MultiplexedStreamType( @@ -169,28 +161,26 @@ } const std::unique_ptr<std::vector<std::unique_ptr<StreamType>>>& - substream_types() const { + substream_types() const { return substream_types_; } std::unique_ptr<StreamType> Clone() const override; -private: + private: std::unique_ptr<StreamType> multiplex_type_; std::unique_ptr<std::vector<std::unique_ptr<StreamType>>> substream_types_; }; // Describes the type of a multiplexed stream. class MultiplexedStreamTypeSet : public StreamTypeSet { -public: + public: static std::unique_ptr<StreamTypeSet> Create( std::unique_ptr<StreamTypeSet> multiplex_type_set, std::unique_ptr<std::vector<std::unique_ptr<StreamTypeSet>>> substream_type_sets) { - return std::unique_ptr<StreamTypeSet>( - new MultiplexedStreamTypeSet( - std::move(multiplex_type_set), - std::move(substream_type_sets))); + return std::unique_ptr<StreamTypeSet>(new MultiplexedStreamTypeSet( + std::move(multiplex_type_set), std::move(substream_type_sets))); } MultiplexedStreamTypeSet( @@ -207,13 +197,13 @@ } const std::unique_ptr<std::vector<std::unique_ptr<StreamTypeSet>>>& - substream_type_sets() const { + substream_type_sets() const { return substream_type_sets_; } std::unique_ptr<StreamTypeSet> Clone() const override; -private: + private: std::unique_ptr<StreamTypeSet> multiplex_type_set_; std::unique_ptr<std::vector<std::unique_ptr<StreamTypeSet>>> substream_type_sets_; @@ -231,44 +221,30 @@ kFloat }; - static std::unique_ptr<StreamType> Create( - SampleFormat sample_format, - uint32_t channels, - uint32_t frames_per_second) { - return std::unique_ptr<StreamType>(new LpcmStreamType( - sample_format, - channels, - frames_per_second)); + static std::unique_ptr<StreamType> Create(SampleFormat sample_format, + uint32_t channels, + uint32_t frames_per_second) { + return std::unique_ptr<StreamType>( + new LpcmStreamType(sample_format, channels, frames_per_second)); } - LpcmStreamType( - SampleFormat sample_format, - uint32_t channels, - uint32_t frames_per_second); + LpcmStreamType(SampleFormat sample_format, + uint32_t channels, + uint32_t frames_per_second); ~LpcmStreamType() override; const LpcmStreamType* lpcm() const override; - SampleFormat sample_format() const { - return sample_format_; - } + SampleFormat sample_format() const { return sample_format_; } - uint32_t channels() const { - return channels_; - } + uint32_t channels() const { return channels_; } - uint32_t frames_per_second() const { - return frames_per_second_; - } + uint32_t frames_per_second() const { return frames_per_second_; } - uint32_t sample_size() const { - return sample_size_; - } + uint32_t sample_size() const { return sample_size_; } - uint32_t bytes_per_frame() const { - return sample_size_ * channels_; - } + uint32_t bytes_per_frame() const { return sample_size_ * channels_; } uint64_t min_buffer_size(uint64_t frame_count) const { return frame_count * bytes_per_frame(); @@ -285,11 +261,10 @@ std::unique_ptr<StreamType> Clone() const override; protected: - LpcmStreamType( - Scheme scheme, - SampleFormat sample_format, - uint32_t channels, - uint32_t frames_per_second); + LpcmStreamType(Scheme scheme, + SampleFormat sample_format, + uint32_t channels, + uint32_t frames_per_second); private: SampleFormat sample_format_; @@ -305,43 +280,33 @@ LpcmStreamType::SampleFormat sample_format, Range<uint32_t> channels, Range<uint32_t> frames_per_second) { - return std::unique_ptr<StreamTypeSet>(new LpcmStreamTypeSet( - sample_format, - channels, - frames_per_second)); + return std::unique_ptr<StreamTypeSet>( + new LpcmStreamTypeSet(sample_format, channels, frames_per_second)); } - LpcmStreamTypeSet( - LpcmStreamType::SampleFormat sample_format, - Range<uint32_t> channels, - Range<uint32_t> frames_per_second); + LpcmStreamTypeSet(LpcmStreamType::SampleFormat sample_format, + Range<uint32_t> channels, + Range<uint32_t> frames_per_second); ~LpcmStreamTypeSet() override; const LpcmStreamTypeSet* lpcm() const override; - LpcmStreamType::SampleFormat sample_format() const { - return sample_format_; - } + LpcmStreamType::SampleFormat sample_format() const { return sample_format_; } - Range<uint32_t> channels() const { - return channels_; - } + Range<uint32_t> channels() const { return channels_; } - Range<uint32_t> frames_per_second() const { - return frames_per_second_; - } + Range<uint32_t> frames_per_second() const { return frames_per_second_; } bool contains(const LpcmStreamType& type) const; std::unique_ptr<StreamTypeSet> Clone() const override; protected: - LpcmStreamTypeSet( - StreamType::Scheme scheme, - LpcmStreamType::SampleFormat sample_format, - Range<uint32_t> channels, - Range<uint32_t> frames_per_second); + LpcmStreamTypeSet(StreamType::Scheme scheme, + LpcmStreamType::SampleFormat sample_format, + Range<uint32_t> channels, + Range<uint32_t> frames_per_second); private: LpcmStreamType::SampleFormat sample_format_; @@ -352,11 +317,7 @@ // Describes the type of a compressed audio stream. class CompressedAudioStreamType : public LpcmStreamType { public: - enum class AudioEncoding { - kUnknown, - kAny, - kVorbis - }; + enum class AudioEncoding { kUnknown, kAny, kVorbis }; static std::unique_ptr<StreamType> Create( AudioEncoding encoding, @@ -365,27 +326,21 @@ uint32_t frames_per_second, std::unique_ptr<Bytes> encoding_details) { return std::unique_ptr<StreamType>(new CompressedAudioStreamType( - encoding, - sample_format, - channels, - frames_per_second, + encoding, sample_format, channels, frames_per_second, std::move(encoding_details))); } - CompressedAudioStreamType( - AudioEncoding encoding, - SampleFormat sample_format, - uint32_t channels, - uint32_t frames_per_second, - std::unique_ptr<Bytes> encoding_details); + CompressedAudioStreamType(AudioEncoding encoding, + SampleFormat sample_format, + uint32_t channels, + uint32_t frames_per_second, + std::unique_ptr<Bytes> encoding_details); ~CompressedAudioStreamType() override; const CompressedAudioStreamType* compressed_audio() const override; - AudioEncoding encoding() const { - return encoding_; - } + AudioEncoding encoding() const { return encoding_; } const std::unique_ptr<Bytes>& encoding_details() const { return encoding_details_; @@ -407,17 +362,14 @@ Range<uint32_t> channels, Range<uint32_t> frames_per_second) { return std::unique_ptr<StreamTypeSet>(new CompressedAudioStreamTypeSet( - encoding, - sample_format, - channels, - frames_per_second)); + encoding, sample_format, channels, frames_per_second)); } CompressedAudioStreamTypeSet( - CompressedAudioStreamType::AudioEncoding encoding, - CompressedAudioStreamType::SampleFormat sample_format, - Range<uint32_t> channels, - Range<uint32_t> frames_per_second); + CompressedAudioStreamType::AudioEncoding encoding, + CompressedAudioStreamType::SampleFormat sample_format, + Range<uint32_t> channels, + Range<uint32_t> frames_per_second); ~CompressedAudioStreamTypeSet() override; @@ -499,63 +451,39 @@ uint32_t coded_height, std::unique_ptr<Bytes> encoding_details) { return std::unique_ptr<StreamType>(new VideoStreamType( - encoding, - profile, - pixel_format, - color_space, - width, - height, - coded_width, - coded_height, - std::move(encoding_details))); + encoding, profile, pixel_format, color_space, width, height, + coded_width, coded_height, std::move(encoding_details))); } - VideoStreamType( - VideoEncoding encoding, - VideoProfile profile, - PixelFormat pixel_format, - ColorSpace color_space, - uint32_t width, - uint32_t height, - uint32_t coded_width, - uint32_t coded_height, - std::unique_ptr<Bytes> encoding_details); + VideoStreamType(VideoEncoding encoding, + VideoProfile profile, + PixelFormat pixel_format, + ColorSpace color_space, + uint32_t width, + uint32_t height, + uint32_t coded_width, + uint32_t coded_height, + std::unique_ptr<Bytes> encoding_details); ~VideoStreamType() override; const VideoStreamType* video() const override; - VideoEncoding encoding() const { - return encoding_; - } + VideoEncoding encoding() const { return encoding_; } - VideoProfile profile() const { - return profile_; - } + VideoProfile profile() const { return profile_; } - PixelFormat pixel_format() const { - return pixel_format_; - } + PixelFormat pixel_format() const { return pixel_format_; } - ColorSpace color_space() const { - return color_space_; - } + ColorSpace color_space() const { return color_space_; } - uint32_t width() const { - return width_; - } + uint32_t width() const { return width_; } - uint32_t height() const { - return height_; - } + uint32_t height() const { return height_; } - uint32_t coded_width() const { - return coded_width_; - } + uint32_t coded_width() const { return coded_width_; } - uint32_t coded_height() const { - return coded_height_; - } + uint32_t coded_height() const { return coded_height_; } const std::unique_ptr<Bytes>& encoding_details() const { return encoding_details_; @@ -582,32 +510,23 @@ VideoStreamType::VideoEncoding encoding, Range<uint32_t> width, Range<uint32_t> height) { - return std::unique_ptr<StreamTypeSet>(new VideoStreamTypeSet( - encoding, - width, - height)); + return std::unique_ptr<StreamTypeSet>( + new VideoStreamTypeSet(encoding, width, height)); } - VideoStreamTypeSet( - VideoStreamType::VideoEncoding encoding, - Range<uint32_t> width, - Range<uint32_t> height); + VideoStreamTypeSet(VideoStreamType::VideoEncoding encoding, + Range<uint32_t> width, + Range<uint32_t> height); ~VideoStreamTypeSet() override; const VideoStreamTypeSet* video() const override; - VideoStreamType::VideoEncoding encoding() const { - return encoding_; - } + VideoStreamType::VideoEncoding encoding() const { return encoding_; } - Range<uint32_t> width() const { - return width_; - } + Range<uint32_t> width() const { return width_; } - Range<uint32_t> height() const { - return height_; - } + Range<uint32_t> height() const { return height_; } std::unique_ptr<StreamTypeSet> Clone() const override; @@ -620,4 +539,4 @@ } // namespace media } // namespace mojo -#endif // SERVICES_MEDIA_FRAMEWORK_STREAM_TYPE_H_ +#endif // SERVICES_MEDIA_FRAMEWORK_STREAM_TYPE_H_
diff --git a/services/media/framework_create/decoder.cc b/services/media/framework_create/decoder.cc index fd3c06d..c931e28 100644 --- a/services/media/framework_create/decoder.cc +++ b/services/media/framework_create/decoder.cc
@@ -8,9 +8,8 @@ namespace mojo { namespace media { -Result Decoder::Create( - const StreamType& stream_type, - std::shared_ptr<Decoder>* decoder_out) { +Result Decoder::Create(const StreamType& stream_type, + std::shared_ptr<Decoder>* decoder_out) { std::shared_ptr<Decoder> decoder; Result result = FfmpegDecoder::Create(stream_type, &decoder); if (result == Result::kOk) { @@ -20,5 +19,5 @@ return result; } -} // namespace media -} // namespace mojo +} // namespace media +} // namespace mojo
diff --git a/services/media/framework_create/demux.cc b/services/media/framework_create/demux.cc index 5285b8b..3896aab 100644 --- a/services/media/framework_create/demux.cc +++ b/services/media/framework_create/demux.cc
@@ -8,9 +8,8 @@ namespace mojo { namespace media { -Result Demux::Create( - std::shared_ptr<Reader> reader, - std::shared_ptr<Demux>* demux_out) { +Result Demux::Create(std::shared_ptr<Reader> reader, + std::shared_ptr<Demux>* demux_out) { std::shared_ptr<Demux> demux = FfmpegDemux::Create(); Result result = demux->Init(reader); @@ -21,5 +20,5 @@ return result; } -} // namespace media -} // namespace mojo +} // namespace media +} // namespace mojo
diff --git a/services/media/framework_ffmpeg/BUILD.gn b/services/media/framework_ffmpeg/BUILD.gn index b06aa61..c6372f6 100644 --- a/services/media/framework_ffmpeg/BUILD.gn +++ b/services/media/framework_ffmpeg/BUILD.gn
@@ -1,6 +1,6 @@ -# Copyright 2016 The Chromium Authors. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. +#Copyright 2016 The Chromium Authors.All rights reserved. +#Use of this source code is governed by a BSD - style license that can be +#found in the LICENSE file. import("//build/module_args/mojo.gni") import("$mojo_sdk_root/mojo/public/mojo_sdk.gni") @@ -12,7 +12,7 @@ "//third_party/ffmpeg", ] - # TODO(dalesat): Why is this needed? + #TODO(dalesat) : Why is this needed ? if (is_android) { include_dirs += [ "//third_party/ffmpeg/chromium/config/Chromium/android/arm" ]
diff --git a/services/media/framework_ffmpeg/av_codec_context.cc b/services/media/framework_ffmpeg/av_codec_context.cc index cd8a3a0..7921c2c 100644 --- a/services/media/framework_ffmpeg/av_codec_context.cc +++ b/services/media/framework_ffmpeg/av_codec_context.cc
@@ -55,16 +55,14 @@ // Creates a StreamType from an AVCodecContext describing an LPCM type. std::unique_ptr<StreamType> StreamTypeFromLpcmCodecContext( const AVCodecContext& from) { - return LpcmStreamType::Create( - Convert(from.sample_fmt), - from.channels, - from.sample_rate); + return LpcmStreamType::Create(Convert(from.sample_fmt), from.channels, + from.sample_rate); } // Creates a StreamType from an AVCodecContext describing a compressed audio // type. -std::unique_ptr<StreamType> -StreamTypeFromCompressedAudioCodecContext(const AVCodecContext& from) { +std::unique_ptr<StreamType> StreamTypeFromCompressedAudioCodecContext( + const AVCodecContext& from) { CompressedAudioStreamType::AudioEncoding encoding; switch (from.codec_id) { case CODEC_ID_VORBIS: @@ -76,13 +74,9 @@ } return CompressedAudioStreamType::Create( - encoding, - Convert(from.sample_fmt), - from.channels, - from.sample_rate, - from.extradata_size == 0 ? - nullptr : - Bytes::Create(from.extradata, from.extradata_size)); + encoding, Convert(from.sample_fmt), from.channels, from.sample_rate, + from.extradata_size == 0 ? nullptr : Bytes::Create(from.extradata, + from.extradata_size)); } // Converts AVColorSpace and AVColorRange to ColorSpace. @@ -133,7 +127,7 @@ case VideoStreamType::VideoProfile::kH264MultiviewHigh: default: return FF_PROFILE_UNKNOWN; - } + } } // Converts an AVPixelFormat to a PixelFormat. @@ -153,7 +147,7 @@ case AV_PIX_FMT_YUVA420P: return VideoStreamType::PixelFormat::kYv12A; default: - return VideoStreamType::PixelFormat::kUnknown; + return VideoStreamType::PixelFormat::kUnknown; } } @@ -192,7 +186,7 @@ const AVCodecContext& from) { VideoStreamType::VideoEncoding encoding; switch (from.codec_id) { - case AV_CODEC_ID_THEORA : + case AV_CODEC_ID_THEORA: encoding = VideoStreamType::VideoEncoding::kTheora; break; case CODEC_ID_VP8: @@ -204,17 +198,12 @@ } return VideoStreamType::Create( - encoding, - VideoStreamType::VideoProfile::kNotApplicable, + encoding, VideoStreamType::VideoProfile::kNotApplicable, PixelFormatFromAVPixelFormat(from.pix_fmt), ColorSpaceFromAVColorSpaceAndRange(from.colorspace, from.color_range), - from.width, - from.height, - from.coded_width, - from.coded_height, - from.extradata_size == 0 ? - nullptr : - Bytes::Create(from.extradata, from.extradata_size)); + from.width, from.height, from.coded_width, from.coded_height, + from.extradata_size == 0 ? nullptr : Bytes::Create(from.extradata, + from.extradata_size)); } // Creates a StreamType from an AVCodecContext describing a data type. @@ -357,7 +346,7 @@ case AVMEDIA_TYPE_VIDEO: return StreamTypeFromVideoCodecContext(from); case AVMEDIA_TYPE_UNKNOWN: - // Treated as AVMEDIA_TYPE_DATA. + // Treated as AVMEDIA_TYPE_DATA. case AVMEDIA_TYPE_DATA: return StreamTypeFromDataCodecContext(from); case AVMEDIA_TYPE_SUBTITLE: @@ -386,5 +375,5 @@ } } -} // namespace media -} // namespace mojo +} // namespace media +} // namespace mojo
diff --git a/services/media/framework_ffmpeg/av_codec_context.h b/services/media/framework_ffmpeg/av_codec_context.h index f5e5ab4..27ad908 100644 --- a/services/media/framework_ffmpeg/av_codec_context.h +++ b/services/media/framework_ffmpeg/av_codec_context.h
@@ -31,4 +31,4 @@ } // namespace media } // namespace mojo -#endif // SERVICES_MEDIA_FRAMEWORK_FFMPEG_AV_CODEC_CONTEXT_H_ +#endif // SERVICES_MEDIA_FRAMEWORK_FFMPEG_AV_CODEC_CONTEXT_H_
diff --git a/services/media/framework_ffmpeg/av_format_context.h b/services/media/framework_ffmpeg/av_format_context.h index 093026b..2ff45a6 100644 --- a/services/media/framework_ffmpeg/av_format_context.h +++ b/services/media/framework_ffmpeg/av_format_context.h
@@ -46,4 +46,4 @@ } // namespace media } // namespace mojo -#endif // SERVICES_MEDIA_FRAMEWORK_FFMPEG_AV_FORMAT_CONTEXT_H_ +#endif // SERVICES_MEDIA_FRAMEWORK_FFMPEG_AV_FORMAT_CONTEXT_H_
diff --git a/services/media/framework_ffmpeg/av_frame.h b/services/media/framework_ffmpeg/av_frame.h index 8b02b66..2942b51 100644 --- a/services/media/framework_ffmpeg/av_frame.h +++ b/services/media/framework_ffmpeg/av_frame.h
@@ -14,21 +14,17 @@ namespace ffmpeg { struct AVFrameDeleter { - inline void operator()(AVFrame* ptr) const { - av_frame_free(&ptr); - } + inline void operator()(AVFrame* ptr) const { av_frame_free(&ptr); } }; using AvFramePtr = std::unique_ptr<AVFrame, AVFrameDeleter>; -struct AvFrame{ - static AvFramePtr Create() { - return AvFramePtr(av_frame_alloc()); - } +struct AvFrame { + static AvFramePtr Create() { return AvFramePtr(av_frame_alloc()); } }; } // namespace ffmpeg } // namespace media } // namespace mojo -#endif // SERVICES_MEDIA_FRAMEWORK_FFMPEG_AV_FRAME_H_ +#endif // SERVICES_MEDIA_FRAMEWORK_FFMPEG_AV_FRAME_H_
diff --git a/services/media/framework_ffmpeg/av_io_context.cc b/services/media/framework_ffmpeg/av_io_context.cc index 2cf4875..6f8ca43 100644 --- a/services/media/framework_ffmpeg/av_io_context.cc +++ b/services/media/framework_ffmpeg/av_io_context.cc
@@ -29,13 +29,9 @@ InitFfmpeg(); AVIOContext* result = avio_alloc_context( - static_cast<unsigned char*>(av_malloc(kBufferSize)), - kBufferSize, - 0, // write_flag - new AvIoContext(reader), - &Read, - nullptr, - &Seek); + static_cast<unsigned char*>(av_malloc(kBufferSize)), kBufferSize, + 0, // write_flag + new AvIoContext(reader), &Read, nullptr, &Seek); // Ensure FFmpeg only tries to seek when we know how. result->seekable = reader->CanSeek() ? AVIO_SEEKABLE_NORMAL : 0; @@ -110,6 +106,5 @@ return position_; } - -} // namespace media -} // namespace mojo +} // namespace media +} // namespace mojo
diff --git a/services/media/framework_ffmpeg/av_io_context.h b/services/media/framework_ffmpeg/av_io_context.h index c860318..f4e5231 100644 --- a/services/media/framework_ffmpeg/av_io_context.h +++ b/services/media/framework_ffmpeg/av_io_context.h
@@ -47,4 +47,4 @@ } // namespace media } // namespace mojo -#endif // SERVICES_MEDIA_FRAMEWORK_FFMPEG_AV_IO_CONTEXT_H_ +#endif // SERVICES_MEDIA_FRAMEWORK_FFMPEG_AV_IO_CONTEXT_H_
diff --git a/services/media/framework_ffmpeg/av_packet.h b/services/media/framework_ffmpeg/av_packet.h index f1d51b8..9ff59e6 100644 --- a/services/media/framework_ffmpeg/av_packet.h +++ b/services/media/framework_ffmpeg/av_packet.h
@@ -15,14 +15,12 @@ namespace ffmpeg { struct AVPacketDeleter { - inline void operator()(AVPacket* ptr) const { - av_free_packet(ptr); - } + inline void operator()(AVPacket* ptr) const { av_free_packet(ptr); } }; using AvPacketPtr = std::unique_ptr<AVPacket, AVPacketDeleter>; -struct AvPacket{ +struct AvPacket { static AvPacketPtr Create() { AVPacket* av_packet = new AVPacket(); av_init_packet(av_packet); @@ -34,4 +32,4 @@ } // namespace media } // namespace mojo -#endif // SERVICES_MEDIA_FRAMEWORK_FFMPEG_AV_PACKET_H_ +#endif // SERVICES_MEDIA_FRAMEWORK_FFMPEG_AV_PACKET_H_
diff --git a/services/media/framework_ffmpeg/ffmpeg_audio_decoder.cc b/services/media/framework_ffmpeg/ffmpeg_audio_decoder.cc index 0d854c1..7c341dc 100644 --- a/services/media/framework_ffmpeg/ffmpeg_audio_decoder.cc +++ b/services/media/framework_ffmpeg/ffmpeg_audio_decoder.cc
@@ -8,8 +8,8 @@ namespace mojo { namespace media { -FfmpegAudioDecoder::FfmpegAudioDecoder(AvCodecContextPtr av_codec_context) : - FfmpegDecoderBase(std::move(av_codec_context)) { +FfmpegAudioDecoder::FfmpegAudioDecoder(AvCodecContextPtr av_codec_context) + : FfmpegDecoderBase(std::move(av_codec_context)) { DCHECK(context()); DCHECK(context()->channels > 0); @@ -28,14 +28,13 @@ void FfmpegAudioDecoder::Flush() { FfmpegDecoderBase::Flush(); - next_pts_= Packet::kUnknownPts; + next_pts_ = Packet::kUnknownPts; } -int FfmpegAudioDecoder::Decode( - const AVPacket& av_packet, - const ffmpeg::AvFramePtr& av_frame_ptr, - PayloadAllocator* allocator, - bool* frame_decoded_out) { +int FfmpegAudioDecoder::Decode(const AVPacket& av_packet, + const ffmpeg::AvFramePtr& av_frame_ptr, + PayloadAllocator* allocator, + bool* frame_decoded_out) { DCHECK(allocator); DCHECK(frame_decoded_out); DCHECK(context()); @@ -57,10 +56,7 @@ int frame_decoded = 0; int input_bytes_used = avcodec_decode_audio4( - context().get(), - av_frame_ptr.get(), - &frame_decoded, - &av_packet); + context().get(), av_frame_ptr.get(), &frame_decoded, &av_packet); *frame_decoded_out = frame_decoded != 0; // We're done with this allocator. @@ -69,9 +65,8 @@ return input_bytes_used; } -PacketPtr FfmpegAudioDecoder::CreateOutputPacket( - const AVFrame& av_frame, - PayloadAllocator* allocator) { +PacketPtr FfmpegAudioDecoder::CreateOutputPacket(const AVFrame& av_frame, + PayloadAllocator* allocator) { DCHECK(allocator); int64_t pts = av_frame.pts; @@ -81,7 +76,7 @@ } uint64_t payload_size; - void *payload_buffer; + void* payload_buffer; AvBufferContext* av_buffer_context = reinterpret_cast<AvBufferContext*>(av_buffer_get_opaque(av_frame.buf[0])); @@ -96,11 +91,9 @@ payload_size = stream_type_->lpcm()->min_buffer_size(av_frame.nb_samples); payload_buffer = allocator->AllocatePayloadBuffer(payload_size); - lpcm_util_->Interleave( - av_buffer_context->buffer(), - av_buffer_context->size(), - payload_buffer, - av_frame.nb_samples); + lpcm_util_->Interleave(av_buffer_context->buffer(), + av_buffer_context->size(), payload_buffer, + av_frame.nb_samples); } else { // We don't need to interleave. The interleaved frames are in a buffer that // was allocated from the correct allocator. We take ownership of the buffer @@ -111,10 +104,8 @@ return Packet::Create( pts, - false, // The base class is responsible for end-of-stream. - payload_size, - payload_buffer, - allocator); + false, // The base class is responsible for end-of-stream. + payload_size, payload_buffer, allocator); } PacketPtr FfmpegAudioDecoder::CreateOutputEndOfStreamPacket() { @@ -137,11 +128,8 @@ static_cast<AVSampleFormat>(av_frame->format); int buffer_size = av_samples_get_buffer_size( - &av_frame->linesize[0], - av_codec_context->channels, - av_frame->nb_samples, - av_sample_format, - FfmpegAudioDecoder::kChannelAlign); + &av_frame->linesize[0], av_codec_context->channels, av_frame->nb_samples, + av_sample_format, FfmpegAudioDecoder::kChannelAlign); if (buffer_size < 0) { LOG(WARNING) << "av_samples_get_buffer_size failed"; return buffer_size; @@ -192,28 +180,23 @@ } av_frame->buf[0] = av_buffer_create( - buffer, - buffer_size, - ReleaseBufferForAvFrame, - av_buffer_context, - 0); // flags + buffer, buffer_size, ReleaseBufferForAvFrame, av_buffer_context, + 0); // flags return 0; } -void FfmpegAudioDecoder::ReleaseBufferForAvFrame( - void* opaque, - uint8_t* buffer) { +void FfmpegAudioDecoder::ReleaseBufferForAvFrame(void* opaque, + uint8_t* buffer) { AvBufferContext* av_buffer_context = reinterpret_cast<AvBufferContext*>(opaque); DCHECK(av_buffer_context); // Either this buffer has already been released to someone else's ownership, // or it's the same as the buffer parameter. - DCHECK( - av_buffer_context->buffer() == nullptr || - av_buffer_context->buffer() == buffer); + DCHECK(av_buffer_context->buffer() == nullptr || + av_buffer_context->buffer() == buffer); delete av_buffer_context; } -} // namespace media -} // namespace mojo +} // namespace media +} // namespace mojo
diff --git a/services/media/framework_ffmpeg/ffmpeg_audio_decoder.h b/services/media/framework_ffmpeg/ffmpeg_audio_decoder.h index 9a8d6dc..88dba7d 100644 --- a/services/media/framework_ffmpeg/ffmpeg_audio_decoder.h +++ b/services/media/framework_ffmpeg/ffmpeg_audio_decoder.h
@@ -22,15 +22,13 @@ // FfmpegDecoderBase overrides. void Flush() override; - int Decode( - const AVPacket& av_packet, - const ffmpeg::AvFramePtr& av_frame_ptr, - PayloadAllocator* allocator, - bool* frame_decoded_out) override; + int Decode(const AVPacket& av_packet, + const ffmpeg::AvFramePtr& av_frame_ptr, + PayloadAllocator* allocator, + bool* frame_decoded_out) override; - PacketPtr CreateOutputPacket( - const AVFrame& av_frame, - PayloadAllocator* allocator) override; + PacketPtr CreateOutputPacket(const AVFrame& av_frame, + PayloadAllocator* allocator) override; PacketPtr CreateOutputEndOfStreamPacket() override; @@ -38,15 +36,14 @@ // Used to control deallocation of buffers. class AvBufferContext { public: - AvBufferContext(size_t size, PayloadAllocator* allocator) : - size_(size), - allocator_(allocator) { + AvBufferContext(size_t size, PayloadAllocator* allocator) + : size_(size), allocator_(allocator) { DCHECK(allocator_); if (size_ == 0) { buffer_ = nullptr; } else { - buffer_ = static_cast<uint8_t*>( - allocator_->AllocatePayloadBuffer(size_)); + buffer_ = + static_cast<uint8_t*>(allocator_->AllocatePayloadBuffer(size_)); } } @@ -92,10 +89,9 @@ static const int kChannelAlign = 32; // Callback used by the ffmpeg decoder to acquire a buffer. - static int AllocateBufferForAvFrame( - AVCodecContext* av_codec_context, - AVFrame* av_frame, - int flags); + static int AllocateBufferForAvFrame(AVCodecContext* av_codec_context, + AVFrame* av_frame, + int flags); // Callback used by the ffmpeg decoder to release a buffer. static void ReleaseBufferForAvFrame(void* opaque, uint8_t* buffer); @@ -112,10 +108,10 @@ std::unique_ptr<StreamType> stream_type_; // Used to supply missing PTS. - int64_t next_pts_= Packet::kUnknownPts; + int64_t next_pts_ = Packet::kUnknownPts; }; } // namespace media } // namespace mojo -#endif // SERVICES_MEDIA_FRAMEWORK_FFMPEG_FFMPEG_AUDIO_DECODER_H_ +#endif // SERVICES_MEDIA_FRAMEWORK_FFMPEG_FFMPEG_AUDIO_DECODER_H_
diff --git a/services/media/framework_ffmpeg/ffmpeg_decoder.cc b/services/media/framework_ffmpeg/ffmpeg_decoder.cc index 77de514..d482e6b 100644 --- a/services/media/framework_ffmpeg/ffmpeg_decoder.cc +++ b/services/media/framework_ffmpeg/ffmpeg_decoder.cc
@@ -10,9 +10,8 @@ namespace mojo { namespace media { -Result FfmpegDecoder::Create( - const StreamType& stream_type, - std::shared_ptr<Decoder>* decoder_out) { +Result FfmpegDecoder::Create(const StreamType& stream_type, + std::shared_ptr<Decoder>* decoder_out) { DCHECK(decoder_out); AvCodecContextPtr av_codec_context(AvCodecContext::Create(stream_type)); @@ -46,5 +45,5 @@ return Result::kOk; } -} // namespace media -} // namespace mojo +} // namespace media +} // namespace mojo
diff --git a/services/media/framework_ffmpeg/ffmpeg_decoder.h b/services/media/framework_ffmpeg/ffmpeg_decoder.h index 8f316d0..d42d2eb 100644 --- a/services/media/framework_ffmpeg/ffmpeg_decoder.h +++ b/services/media/framework_ffmpeg/ffmpeg_decoder.h
@@ -18,12 +18,11 @@ class FfmpegDecoder : public Decoder { public: // Creates an ffmpeg-based Decoder object for a given media type. - static Result Create( - const StreamType& stream_type, - std::shared_ptr<Decoder>* decoder_out); + static Result Create(const StreamType& stream_type, + std::shared_ptr<Decoder>* decoder_out); }; } // namespace media } // namespace mojo -#endif // SERVICES_MEDIA_FRAMEWORK_FFMPEG_FFMPEG_DECODER_H_ +#endif // SERVICES_MEDIA_FRAMEWORK_FFMPEG_FFMPEG_DECODER_H_
diff --git a/services/media/framework_ffmpeg/ffmpeg_decoder_base.cc b/services/media/framework_ffmpeg/ffmpeg_decoder_base.cc index 60a0385..2c37acd 100644 --- a/services/media/framework_ffmpeg/ffmpeg_decoder_base.cc +++ b/services/media/framework_ffmpeg/ffmpeg_decoder_base.cc
@@ -9,9 +9,9 @@ namespace mojo { namespace media { -FfmpegDecoderBase::FfmpegDecoderBase(AvCodecContextPtr av_codec_context) : - av_codec_context_(std::move(av_codec_context)), - av_frame_ptr_(av_frame_alloc()) { +FfmpegDecoderBase::FfmpegDecoderBase(AvCodecContextPtr av_codec_context) + : av_codec_context_(std::move(av_codec_context)), + av_frame_ptr_(av_frame_alloc()) { DCHECK(av_codec_context_); } @@ -26,11 +26,10 @@ avcodec_flush_buffers(av_codec_context_.get()); } -bool FfmpegDecoderBase::TransformPacket( - const PacketPtr& input, - bool new_input, - PayloadAllocator* allocator, - PacketPtr* output) { +bool FfmpegDecoderBase::TransformPacket(const PacketPtr& input, + bool new_input, + PayloadAllocator* allocator, + PacketPtr* output) { DCHECK(input); DCHECK(allocator); DCHECK(output); @@ -79,9 +78,8 @@ av_packet_.pts = input->pts(); } -bool FfmpegDecoderBase::UnprepareInputPacket( - const PacketPtr& input, - PacketPtr* output) { +bool FfmpegDecoderBase::UnprepareInputPacket(const PacketPtr& input, + PacketPtr* output) { if (input->end_of_stream()) { // Indicate end of stream. This happens when we're draining for the last // time, so there should be no output packet yet. @@ -95,5 +93,5 @@ return true; } -} // namespace media -} // namespace mojo +} // namespace media +} // namespace mojo
diff --git a/services/media/framework_ffmpeg/ffmpeg_decoder_base.h b/services/media/framework_ffmpeg/ffmpeg_decoder_base.h index 4d7d869..3cb4afe 100644 --- a/services/media/framework_ffmpeg/ffmpeg_decoder_base.h +++ b/services/media/framework_ffmpeg/ffmpeg_decoder_base.h
@@ -29,34 +29,29 @@ // Transform implementation. void Flush() override; - bool TransformPacket( - const PacketPtr& input, - bool new_input, - PayloadAllocator* allocator, - PacketPtr* output) override; + bool TransformPacket(const PacketPtr& input, + bool new_input, + PayloadAllocator* allocator, + PacketPtr* output) override; protected: // Decodes from av_packet into av_frame_ptr. The result indicates how many // bytes were consumed from av_packet_. *frame_decoded_out indicates whether // av_frame_ptr contains a complete frame. - virtual int Decode( - const AVPacket& av_packet, - const ffmpeg::AvFramePtr& av_frame_ptr, - PayloadAllocator* allocator, - bool* frame_decoded_out) = 0; + virtual int Decode(const AVPacket& av_packet, + const ffmpeg::AvFramePtr& av_frame_ptr, + PayloadAllocator* allocator, + bool* frame_decoded_out) = 0; // Creates a Packet from av_frame. - virtual PacketPtr CreateOutputPacket( - const AVFrame& av_frame, - PayloadAllocator* allocator) = 0; + virtual PacketPtr CreateOutputPacket(const AVFrame& av_frame, + PayloadAllocator* allocator) = 0; // Creates an end-of-stream packet with no payload. virtual PacketPtr CreateOutputEndOfStreamPacket() = 0; // The ffmpeg codec context. - const AvCodecContextPtr& context() { - return av_codec_context_; - } + const AvCodecContextPtr& context() { return av_codec_context_; } private: // Prepares to process a new input packet. @@ -75,4 +70,4 @@ } // namespace media } // namespace mojo -#endif // SERVICES_MEDIA_FRAMEWORK_FFMPEG_FFMPEG_DECODER_BASE_H_ +#endif // SERVICES_MEDIA_FRAMEWORK_FFMPEG_FFMPEG_DECODER_BASE_H_
diff --git a/services/media/framework_ffmpeg/ffmpeg_demux.cc b/services/media/framework_ffmpeg/ffmpeg_demux.cc index 7eacdd9..cb915e8 100644 --- a/services/media/framework_ffmpeg/ffmpeg_demux.cc +++ b/services/media/framework_ffmpeg/ffmpeg_demux.cc
@@ -60,9 +60,7 @@ return PacketPtr(new DemuxPacket(std::move(av_packet))); } - AVPacket& av_packet() { - return *av_packet_; - } + AVPacket& av_packet() { return *av_packet_; } protected: ~DemuxPacket() override {} @@ -70,13 +68,13 @@ void Release() override { delete this; } private: - DemuxPacket(ffmpeg::AvPacketPtr av_packet) : - Packet( - (av_packet->pts == AV_NOPTS_VALUE) ? kUnknownPts : av_packet->pts, - false, - static_cast<size_t>(av_packet->size), - av_packet->data), - av_packet_(std::move(av_packet)) { + DemuxPacket(ffmpeg::AvPacketPtr av_packet) + : Packet( + (av_packet->pts == AV_NOPTS_VALUE) ? kUnknownPts : av_packet->pts, + false, + static_cast<size_t>(av_packet->size), + av_packet->data), + av_packet_(std::move(av_packet)) { DCHECK(av_packet_->size >= 0); } @@ -93,9 +91,8 @@ PacketPtr PullEndOfStreamPacket(size_t* stream_index_out); // Copies metadata from the specified source into map. - void CopyMetadata( - AVDictionary* source, - std::map<std::string, std::string>& map); + void CopyMetadata(AVDictionary* source, + std::map<std::string, std::string>& map); std::shared_ptr<Reader> reader_; AvFormatContextPtr format_context_; @@ -103,7 +100,7 @@ std::vector<DemuxStream*> streams_; std::unique_ptr<Metadata> metadata_; int64_t next_pts_; - int next_stream_to_end_ = -1; // -1: don't end, streams_.size(): stop. + int next_stream_to_end_ = -1; // -1: don't end, streams_.size(): stop. }; // static @@ -147,14 +144,11 @@ CopyMetadata(format_context_->streams[i]->metadata, metadata_map); } - metadata_ = Metadata::Create( - format_context_->duration * kNanosecondsPerMicrosecond, - metadata_map["TITLE"], - metadata_map["ARTIST"], - metadata_map["ALBUM"], - metadata_map["PUBLISHER"], - metadata_map["GENRE"], - metadata_map["COMPOSER"]); + metadata_ = + Metadata::Create(format_context_->duration * kNanosecondsPerMicrosecond, + metadata_map["TITLE"], metadata_map["ARTIST"], + metadata_map["ALBUM"], metadata_map["PUBLISHER"], + metadata_map["GENRE"], metadata_map["COMPOSER"]); return Result::kOk; } @@ -201,8 +195,7 @@ return PullEndOfStreamPacket(stream_index_out); } - *stream_index_out = - static_cast<size_t>(av_packet->stream_index); + *stream_index_out = static_cast<size_t>(av_packet->stream_index); // TODO(dalesat): What if the packet has no PTS or duration? next_pts_ = av_packet->pts + av_packet->duration; @@ -221,17 +214,16 @@ return Packet::CreateEndOfStream(next_pts_); } -void FfmpegDemuxImpl::CopyMetadata( - AVDictionary* source, - std::map<std::string, std::string>& map) { +void FfmpegDemuxImpl::CopyMetadata(AVDictionary* source, + std::map<std::string, std::string>& map) { if (source == nullptr) { return; } - for (AVDictionaryEntry *entry = - av_dict_get(source, "", nullptr, AV_DICT_IGNORE_SUFFIX); - entry != nullptr; - entry = av_dict_get(source, "", entry, AV_DICT_IGNORE_SUFFIX)) { + for (AVDictionaryEntry* entry = + av_dict_get(source, "", nullptr, AV_DICT_IGNORE_SUFFIX); + entry != nullptr; + entry = av_dict_get(source, "", entry, AV_DICT_IGNORE_SUFFIX)) { if (map.find(entry->key) == map.end()) { map.emplace(entry->key, entry->value); } @@ -240,8 +232,8 @@ FfmpegDemuxImpl::FfmpegDemuxStream::FfmpegDemuxStream( const AVFormatContext& format_context, - size_t index) : - stream_(format_context.streams[index]), index_(index) { + size_t index) + : stream_(format_context.streams[index]), index_(index) { stream_type_ = AvCodecContext::GetStreamType(*stream_->codec); } @@ -256,5 +248,5 @@ return SafeClone(stream_type_); } -} // namespace media -} // namespace mojo +} // namespace media +} // namespace mojo
diff --git a/services/media/framework_ffmpeg/ffmpeg_demux.h b/services/media/framework_ffmpeg/ffmpeg_demux.h index 281fb17..bf795b8 100644 --- a/services/media/framework_ffmpeg/ffmpeg_demux.h +++ b/services/media/framework_ffmpeg/ffmpeg_demux.h
@@ -20,4 +20,4 @@ } // namespace media } // namespace mojo -#endif // SERVICES_MEDIA_FRAMEWORK_FFMPEG_FFMPEG_DEMUX_H_ +#endif // SERVICES_MEDIA_FRAMEWORK_FFMPEG_FFMPEG_DEMUX_H_
diff --git a/services/media/framework_ffmpeg/ffmpeg_formatting.cc b/services/media/framework_ffmpeg/ffmpeg_formatting.cc index 2367311..322cab6 100644 --- a/services/media/framework_ffmpeg/ffmpeg_formatting.cc +++ b/services/media/framework_ffmpeg/ffmpeg_formatting.cc
@@ -18,13 +18,12 @@ return s == nullptr ? "<nullptr>" : s; } -std::ostream& operator<<( - std::ostream& os, - const struct AVCodecTag *const *value) { +std::ostream& operator<<(std::ostream& os, + const struct AVCodecTag* const* value) { if (value == nullptr) { return os << "<nullptr>" << std::endl; } else if (*value == nullptr) { - return os << "&<nullptr>" << std::endl; + return os << "&<nullptr>" << std::endl; } else { os << std::endl; } @@ -35,7 +34,7 @@ return os << outdent; } -std::ostream& operator<<(std::ostream& os, const AVInputFormat *value) { +std::ostream& operator<<(std::ostream& os, const AVInputFormat* value) { if (value == nullptr) { return os << "<nullptr>" << std::endl; } else { @@ -47,14 +46,14 @@ os << begl << "const char *long_name: " << value->long_name << std::endl; os << begl << "int flags: " << AVFMTFlags(value->flags); os << begl << "const char *extensions: " << safe(value->extensions) - << std::endl; + << std::endl; os << begl << "const AVCodecTag * const *codec_tag: " << value->codec_tag; os << begl << "const char *mime_type: " << safe(value->mime_type) - << std::endl; + << std::endl; return os << outdent; } -std::ostream& operator<<(std::ostream& os, const AVOutputFormat *value) { +std::ostream& operator<<(std::ostream& os, const AVOutputFormat* value) { if (value == nullptr) { return os << "<nullptr>" << std::endl; } else { @@ -64,11 +63,11 @@ os << indent; os << begl << "const char *name: " << safe(value->name) << std::endl; os << begl << "const char *long_name: " << safe(value->long_name) - << std::endl; + << std::endl; os << begl << "const char *mime_type: " << safe(value->mime_type) - << std::endl; + << std::endl; os << begl << "const char *extensions: " << safe(value->extensions) - << std::endl; + << std::endl; os << begl << "AVCodecID audio_codec: " << value->audio_codec; os << begl << "AVCodecID video_codec: " << value->video_codec; os << begl << "AVCodecID subtitle_codec: " << value->subtitle_codec; @@ -77,7 +76,7 @@ return os << outdent; } -std::ostream& operator<<(std::ostream& os, const AVIOContext *value) { +std::ostream& operator<<(std::ostream& os, const AVIOContext* value) { if (value == nullptr) { return os << "<nullptr>" << std::endl; } else { @@ -97,7 +96,7 @@ } } -std::ostream& operator<<(std::ostream& os, const AVRational *value) { +std::ostream& operator<<(std::ostream& os, const AVRational* value) { if (value == nullptr) { return os << "<none>" << std::endl; } else { @@ -111,7 +110,7 @@ return os << outdent; } -std::ostream& operator<<(std::ostream& os, const int *value) { +std::ostream& operator<<(std::ostream& os, const int* value) { if (value == nullptr) { return os << "<none>" << std::endl; } else { @@ -125,7 +124,7 @@ return os << outdent; } -std::ostream& operator<<(std::ostream& os, const uint64_t *value) { +std::ostream& operator<<(std::ostream& os, const uint64_t* value) { if (value == nullptr) { return os << "<none>" << std::endl; } else { @@ -139,7 +138,7 @@ return os << outdent; } -std::ostream& operator<<(std::ostream& os, const AVSampleFormat *value) { +std::ostream& operator<<(std::ostream& os, const AVSampleFormat* value) { if (value == nullptr) { return os << "<none>" << std::endl; } else { @@ -153,7 +152,7 @@ return os << outdent; } -std::ostream& operator<<(std::ostream& os, const AVCodec *value) { +std::ostream& operator<<(std::ostream& os, const AVCodec* value) { if (value == nullptr) { return os << "<nullptr>" << std::endl; } else { @@ -163,21 +162,21 @@ os << indent; os << begl << "const char *name: " << safe(value->name) << std::endl; os << begl << "const char *long_name: " << safe(value->long_name) - << std::endl; + << std::endl; os << begl << "AVMediaType type: " << value->type; os << begl << "AVCodecID id: " << value->id; os << begl << "int capabilities: " << value->capabilities << std::endl; - os << begl << "AVRational *supported_framerates: " - << value->supported_framerates; - os << begl << "const int *supported_samplerates: " - << value->supported_samplerates; + os << begl + << "AVRational *supported_framerates: " << value->supported_framerates; + os << begl + << "const int *supported_samplerates: " << value->supported_samplerates; os << begl << "const AVSampleFormat *sample_fmts: " << value->sample_fmts; os << begl << "const uint64_t *channel_layouts: " << value->channel_layouts; return os << outdent; } -std::ostream& operator<<(std::ostream& os, const AVCodecContext *value) { +std::ostream& operator<<(std::ostream& os, const AVCodecContext* value) { if (value == nullptr) { return os << "<nullptr>" << std::endl; } else { @@ -203,14 +202,16 @@ os << begl << "int block_align: " << value->block_align << std::endl; os << begl << "int cutoff: " << value->cutoff << std::endl; os << begl << "uint64_t channel_layout: " << value->channel_layout - << std::endl; - os << begl << "uint64_t request_channel_layout: " - << value->request_channel_layout << std::endl; - os << begl << "AVAudioServiceType audio_service_type: " - << value->audio_service_type << std::endl; - os << begl << "AVSampleFormat request_sample_fmt: " - << value->request_sample_fmt; - os << begl << "int profile: " << value->profile << std::endl; + << std::endl; + os << begl + << "uint64_t request_channel_layout: " << value->request_channel_layout + << std::endl; + os << begl + << "AVAudioServiceType audio_service_type: " << value->audio_service_type + << std::endl; + os << begl + << "AVSampleFormat request_sample_fmt: " << value->request_sample_fmt; + os << begl << "int profile: " << value->profile << std::endl; return os << outdent; } @@ -218,7 +219,7 @@ return os << value.num << "/" << value.den << std::endl; } -std::ostream& operator<<(std::ostream& os, const AVStream *value) { +std::ostream& operator<<(std::ostream& os, const AVStream* value) { if (value == nullptr) { return os << "<nullptr>" << std::endl; } else { @@ -235,14 +236,14 @@ os << begl << "int64_t nb_frames: " << value->nb_frames << std::endl; os << begl << "int disposition: " << AV_DISPOSITIONFlags(value->disposition); os << begl << "AVDiscard discard: " << value->discard; - os << begl << "AVRational sample_aspect_ratio: " - << value->sample_aspect_ratio; + os << begl + << "AVRational sample_aspect_ratio: " << value->sample_aspect_ratio; os << begl << "AVDictionary *metadata: " << value->metadata; os << begl << "AVRational avg_frame_rate: " << value->avg_frame_rate; os << begl << "AVPacket attached_pic: " << &value->attached_pic; os << begl << "int nb_side_data: " << value->nb_side_data << std::endl; - os << begl << "AVPacketSideData side_data: " << - AVPacketSideDataArray(value->side_data, value->nb_side_data); + os << begl << "AVPacketSideData side_data: " + << AVPacketSideDataArray(value->side_data, value->nb_side_data); os << begl << "int event_flags: " << AVSTREAM_EVENTFlags(value->event_flags); return os << outdent; } @@ -353,7 +354,7 @@ return os << outdent; } -std::ostream& operator<<(std::ostream& os, const AVBufferRef *value) { +std::ostream& operator<<(std::ostream& os, const AVBufferRef* value) { if (value == nullptr) { return os << "<nullptr>" << std::endl; } else { @@ -362,14 +363,15 @@ os << indent; os << begl << "AVBuffer *buffer: " - << (value->buffer == nullptr ? "<nullptr>" : "TODO") << std::endl; - os << begl << "uint8_t *data: " - << (value->data == nullptr ? "<nullptr>" : "<opaque>") << std::endl; + << (value->buffer == nullptr ? "<nullptr>" : "TODO") << std::endl; + os << begl + << "uint8_t *data: " << (value->data == nullptr ? "<nullptr>" : "<opaque>") + << std::endl; os << begl << "int size: " << value->size << std::endl; return os << outdent; } -std::ostream& operator<<(std::ostream& os, const AVFrame *value) { +std::ostream& operator<<(std::ostream& os, const AVFrame* value) { if (value == nullptr) { return os << "<nullptr>" << std::endl; } else { @@ -416,8 +418,8 @@ } os << begl << "uint8_t **extended_data: " - << (value->extended_data == nullptr ? "<nullptr>" : "<opaque>") - << std::endl; + << (value->extended_data == nullptr ? "<nullptr>" : "<opaque>") + << std::endl; os << begl << "int width: " << value->width << std::endl; os << begl << "int height: " << value->height << std::endl; os << begl << "int nb_samples: " << value->nb_samples << std::endl; @@ -450,7 +452,7 @@ return os << outdent; } -std::ostream& operator<<(std::ostream& os, const AVPacket *value) { +std::ostream& operator<<(std::ostream& os, const AVPacket* value) { if (value == nullptr) { return os << "<nullptr>" << std::endl; } else { @@ -461,8 +463,9 @@ os << begl << "AVBufferRef *buf: " << value->buf; os << begl << "int64_t pts: " << value->pts << std::endl; os << begl << "int64_t dts: " << value->dts << std::endl; - os << begl << "uint8_t *data: " - << (value->data == nullptr ? "<nullptr>" : "<opaque>") << std::endl; + os << begl + << "uint8_t *data: " << (value->data == nullptr ? "<nullptr>" : "<opaque>") + << std::endl; os << begl << "int size: " << value->size << std::endl; os << begl << "int stream_index: " << value->stream_index << std::endl; os << begl << "int flags: " << value->flags << std::endl; @@ -470,12 +473,12 @@ os << begl << "int side_data_elems: " << value->side_data_elems << std::endl; os << begl << "int duration: " << value->duration << std::endl; os << begl << "int64_t pos: " << value->pos << std::endl; - os << begl << "int64_t convergence_duration: " - << value->convergence_duration << std::endl; + os << begl << "int64_t convergence_duration: " << value->convergence_duration + << std::endl; return os << outdent; } -std::ostream& operator<<(std::ostream& os, const AVPacketSideData *value) { +std::ostream& operator<<(std::ostream& os, const AVPacketSideData* value) { if (value == nullptr) { return os << "<nullptr>" << std::endl; } else { @@ -499,7 +502,7 @@ return os << outdent; } -std::ostream& operator<<(std::ostream& os, const AVProgram *value) { +std::ostream& operator<<(std::ostream& os, const AVProgram* value) { if (value == nullptr) { return os << "<nullptr>" << std::endl; } else { @@ -523,7 +526,7 @@ return os << outdent; } -std::ostream& operator<<(std::ostream& os, const AVChapter *value) { +std::ostream& operator<<(std::ostream& os, const AVChapter* value) { if (value == nullptr) { return os << "<nullptr>" << std::endl; } else { @@ -549,14 +552,14 @@ std::ostream& operator<<(std::ostream& os, AVCodecID value) { return os << avcodec_get_name(value) << " (" << static_cast<int>(value) << ")" - << std::endl; + << std::endl; } -std::ostream& operator<<(std::ostream& os, const AVDictionary *value) { +std::ostream& operator<<(std::ostream& os, const AVDictionary* value) { if (value == nullptr) { return os << "<nullptr>" << std::endl; } - AVDictionaryEntry *entry = + AVDictionaryEntry* entry = av_dict_get(value, "", nullptr, AV_DICT_IGNORE_SUFFIX); if (entry == nullptr) { return os << "<empty>" << std::endl; @@ -581,7 +584,7 @@ return os << "AVFMT_EVENT_FLAG_METADATA_UPDATED" << std::endl; } else { return os << "<UNKNOWN AVFMT_EVENT_FLAG_: " << value.flags_ << ">" - << std::endl; + << std::endl; } } @@ -595,7 +598,7 @@ return os << "AVSTREAM_EVENT_FLAG_METADATA_UPDATED" << std::endl; } else { return os << "<UNKNOWN AVSTREAM_EVENT_FLAG_: " << value.flags_ << ">" - << std::endl; + << std::endl; } } @@ -609,7 +612,7 @@ return os << "AVFMT_AVOID_NEG_TS_MAKE_ZERO" << std::endl; default: return os << "<UNKNOWN AVFMT_AVOID_NEG_TS_: " << value.flags_ << ">" - << std::endl; + << std::endl; } } @@ -631,7 +634,7 @@ return os << "AVMEDIA_TYPE_NB" << std::endl; default: return os << "<UNKNOWN AVMediaType: " << static_cast<int>(value) << ">" - << std::endl; + << std::endl; } } @@ -663,7 +666,7 @@ return os << "AV_SAMPLE_FMT_NB" << std::endl; default: return os << "<UNKNOWN AVSampleFormat: " << static_cast<int>(value) << ">" - << std::endl; + << std::endl; } } @@ -695,7 +698,7 @@ return os << "AVCOL_SPC_NB" << std::endl; default: return os << "<UNKNOWN AVColorSpace: " << static_cast<int>(value) << ">" - << std::endl; + << std::endl; } } @@ -717,7 +720,7 @@ return os << "AVDISCARD_ALL" << std::endl; default: return os << "<UNKNOWN AVDISCARD_: " << static_cast<int>(value) << ">" - << std::endl; + << std::endl; } } @@ -731,11 +734,11 @@ return os << "AVFMT_DURATION_FROM_BITRATE" << std::endl; default: return os << "<UNKNOWN AVDurationEstimationMethod: " - << static_cast<int>(value) << ">" << std::endl; + << static_cast<int>(value) << ">" << std::endl; } } -std::ostream& operator<<(std::ostream& os, const AVFormatContext *value) { +std::ostream& operator<<(std::ostream& os, const AVFormatContext* value) { if (value == nullptr) { return os << "<nullptr>" << std::endl; } else { @@ -748,8 +751,8 @@ os << begl << "AVIOContext *pb: " << value->pb; os << begl << "int ctx_flags: " << AVFMTCTXFlags(value->ctx_flags); os << begl << "unsigned int nb_streams: " << value->nb_streams << std::endl; - os << begl << "AVStream **streams: " - << AVStreamArray(value->streams, value->nb_streams); + os << begl << "AVStream **streams: " << AVStreamArray(value->streams, + value->nb_streams); os << begl << "char filename[1024]: " << value->filename << std::endl; os << begl << "int64_t start_time: " << value->start_time << std::endl; os << begl << "int64_t duration: " << value->duration << std::endl; @@ -759,44 +762,44 @@ os << begl << "int flags: " << AVFMTFlags(value->flags); os << begl << "int64_t probesize: " << value->probesize << std::endl; os << begl << "unsigned int nb_programs: " << value->nb_programs << std::endl; - os << begl << "AVProgram **programs: " - << AVProgramArray(value->programs, value->nb_programs); + os << begl << "AVProgram **programs: " << AVProgramArray(value->programs, + value->nb_programs); os << begl << "AVCodecID video_codec_id: " << value->video_codec_id; os << begl << "AVCodecID audio_codec_id: " << value->audio_codec_id; os << begl << "AVCodecID subtitle_codec_id: " << value->subtitle_codec_id; - os << begl << "unsigned int max_index_size: " - << value->max_index_size << std::endl; - os << begl << "unsigned int max_picture_buffer: " - << value->max_picture_buffer << std::endl; + os << begl << "unsigned int max_index_size: " << value->max_index_size + << std::endl; + os << begl << "unsigned int max_picture_buffer: " << value->max_picture_buffer + << std::endl; os << begl << "unsigned int nb_chapters: " << value->nb_chapters << std::endl; - os << begl << "AVChapter **chapters: " - << AVChapterArray(value->chapters, value->nb_chapters); + os << begl << "AVChapter **chapters: " << AVChapterArray(value->chapters, + value->nb_chapters); os << begl << "AVDictionary *metadata: " << value->metadata; os << begl << "int64_t start_time_realtime: " << value->start_time_realtime - << std::endl; + << std::endl; os << begl << "int fps_probe_size: " << value->fps_probe_size << std::endl; - os << begl << "int error_recognition: " - << value->error_recognition << std::endl; - os << begl << "int64_t max_interleave_delta: " - << value->max_interleave_delta << std::endl; - os << begl << "int strict_std_compliance: " - << value->strict_std_compliance << std::endl; + os << begl << "int error_recognition: " << value->error_recognition + << std::endl; + os << begl << "int64_t max_interleave_delta: " << value->max_interleave_delta + << std::endl; + os << begl << "int strict_std_compliance: " << value->strict_std_compliance + << std::endl; os << begl << "int event_flags: " << AVFMT_EVENTFlags(value->flags); os << begl << "int max_ts_probe: " << value->max_ts_probe << std::endl; os << begl << "int avoid_negative_ts: " - << AVFMT_AVOID_NEG_TSFlags(value->avoid_negative_ts); + << AVFMT_AVOID_NEG_TSFlags(value->avoid_negative_ts); os << begl << "int ts_id: " << value->ts_id << std::endl; os << begl << "int audio_preload: " << value->audio_preload << std::endl; - os << begl << "int max_chunk_duration: " - << value->max_chunk_duration << std::endl; + os << begl << "int max_chunk_duration: " << value->max_chunk_duration + << std::endl; os << begl << "int max_chunk_size: " << value->max_chunk_size << std::endl; os << begl << "int use_wallclock_as_timestamps: " - << value->use_wallclock_as_timestamps << std::endl; + << value->use_wallclock_as_timestamps << std::endl; os << begl << "int avio_flags: " << value->avio_flags << std::endl; os << begl << "AVDurationEstimationMethod duration_estimation_method: " - << value->duration_estimation_method; + << value->duration_estimation_method; os << begl << "int64_t skip_initial_bytes: " << value->skip_initial_bytes - << std::endl; + << std::endl; os << begl << "TODO(dalesat): more" << std::endl; return os << outdent; }
diff --git a/services/media/framework_ffmpeg/ffmpeg_formatting.h b/services/media/framework_ffmpeg/ffmpeg_formatting.h index 05b1ebe..403ba7b 100644 --- a/services/media/framework_ffmpeg/ffmpeg_formatting.h +++ b/services/media/framework_ffmpeg/ffmpeg_formatting.h
@@ -17,59 +17,58 @@ // See services/media/framework/ostream.h for details. -std::ostream& operator<<( - std::ostream& os, - const struct AVCodecTag *const *value); -std::ostream& operator<<(std::ostream& os, const AVInputFormat *value); -std::ostream& operator<<(std::ostream& os, const AVOutputFormat *value); -std::ostream& operator<<(std::ostream& os, const AVIOContext *value); -std::ostream& operator<<(std::ostream& os, const AVCodecContext *value); -std::ostream& operator<<(std::ostream& os, const AVCodec *value); +std::ostream& operator<<(std::ostream& os, + const struct AVCodecTag* const* value); +std::ostream& operator<<(std::ostream& os, const AVInputFormat* value); +std::ostream& operator<<(std::ostream& os, const AVOutputFormat* value); +std::ostream& operator<<(std::ostream& os, const AVIOContext* value); +std::ostream& operator<<(std::ostream& os, const AVCodecContext* value); +std::ostream& operator<<(std::ostream& os, const AVCodec* value); std::ostream& operator<<(std::ostream& os, const AVRational& value); -std::ostream& operator<<(std::ostream& os, const AVStream *value); -std::ostream& operator<<(std::ostream& os, const AVBufferRef *value); -std::ostream& operator<<(std::ostream& os, const AVFrame *value); -std::ostream& operator<<(std::ostream& os, const AVPacket *value); -std::ostream& operator<<(std::ostream& os, const AVPacketSideData *value); -std::ostream& operator<<(std::ostream& os, const AVProgram *value); -std::ostream& operator<<(std::ostream& os, const AVChapter *value); +std::ostream& operator<<(std::ostream& os, const AVStream* value); +std::ostream& operator<<(std::ostream& os, const AVBufferRef* value); +std::ostream& operator<<(std::ostream& os, const AVFrame* value); +std::ostream& operator<<(std::ostream& os, const AVPacket* value); +std::ostream& operator<<(std::ostream& os, const AVPacketSideData* value); +std::ostream& operator<<(std::ostream& os, const AVProgram* value); +std::ostream& operator<<(std::ostream& os, const AVChapter* value); std::ostream& operator<<(std::ostream& os, AVCodecID value); -std::ostream& operator<<(std::ostream& os, const AVDictionary *value); +std::ostream& operator<<(std::ostream& os, const AVDictionary* value); std::ostream& operator<<(std::ostream& os, enum AVDiscard value); std::ostream& operator<<(std::ostream& os, AVDurationEstimationMethod value); -std::ostream& operator<<(std::ostream& os, const AVFormatContext *value); +std::ostream& operator<<(std::ostream& os, const AVFormatContext* value); std::ostream& operator<<(std::ostream& os, AVMediaType value); std::ostream& operator<<(std::ostream& os, AVSampleFormat value); std::ostream& operator<<(std::ostream& os, AVColorSpace value); struct AVPacketSideDataArray { - AVPacketSideDataArray(const AVPacketSideData *items, unsigned int count) : - items_(items), count_(count) {} - const AVPacketSideData *items_; + AVPacketSideDataArray(const AVPacketSideData* items, unsigned int count) + : items_(items), count_(count) {} + const AVPacketSideData* items_; unsigned int count_; }; std::ostream& operator<<(std::ostream& os, const AVPacketSideDataArray& value); struct AVProgramArray { - AVProgramArray(AVProgram **items, unsigned int count) : - items_(items), count_(count) {} - AVProgram **items_; + AVProgramArray(AVProgram** items, unsigned int count) + : items_(items), count_(count) {} + AVProgram** items_; unsigned int count_; }; std::ostream& operator<<(std::ostream& os, const AVProgramArray& value); struct AVChapterArray { - AVChapterArray(AVChapter **items, unsigned int count) : - items_(items), count_(count) {} - AVChapter **items_; + AVChapterArray(AVChapter** items, unsigned int count) + : items_(items), count_(count) {} + AVChapter** items_; unsigned int count_; }; std::ostream& operator<<(std::ostream& os, const AVChapterArray& value); struct AVStreamArray { - AVStreamArray(AVStream **items, unsigned int count) : - items_(items), count_(count) {} - AVStream **items_; + AVStreamArray(AVStream** items, unsigned int count) + : items_(items), count_(count) {} + AVStream** items_; unsigned int count_; }; std::ostream& operator<<(std::ostream& os, const AVStreamArray& value); @@ -113,4 +112,4 @@ } // namespace media } // namespace mojo -#endif // SERVICES_MEDIA_FRAMEWORK_FFMPEG_FFMPEG_FORMATTING_H_ +#endif // SERVICES_MEDIA_FRAMEWORK_FFMPEG_FFMPEG_FORMATTING_H_
diff --git a/services/media/framework_ffmpeg/ffmpeg_init.cc b/services/media/framework_ffmpeg/ffmpeg_init.cc index 4ce9e62..63e27b1 100644 --- a/services/media/framework_ffmpeg/ffmpeg_init.cc +++ b/services/media/framework_ffmpeg/ffmpeg_init.cc
@@ -23,5 +23,5 @@ } } -} // namespace media -} // namespace mojo +} // namespace media +} // namespace mojo
diff --git a/services/media/framework_ffmpeg/ffmpeg_init.h b/services/media/framework_ffmpeg/ffmpeg_init.h index 7de4223..75aedf1 100644 --- a/services/media/framework_ffmpeg/ffmpeg_init.h +++ b/services/media/framework_ffmpeg/ffmpeg_init.h
@@ -13,4 +13,4 @@ } // namespace media } // namespace mojo -#endif // SERVICES_MEDIA_FRAMEWORK_FFMPEG_FFMPEG_INIT_H_ +#endif // SERVICES_MEDIA_FRAMEWORK_FFMPEG_FFMPEG_INIT_H_
diff --git a/services/media/framework_ffmpeg/ffmpeg_video_decoder.cc b/services/media/framework_ffmpeg/ffmpeg_video_decoder.cc index 73fe12e..312d5dd 100644 --- a/services/media/framework_ffmpeg/ffmpeg_video_decoder.cc +++ b/services/media/framework_ffmpeg/ffmpeg_video_decoder.cc
@@ -8,18 +8,17 @@ namespace mojo { namespace media { -FfmpegVideoDecoder::FfmpegVideoDecoder(AvCodecContextPtr av_codec_context) : - FfmpegDecoderBase(std::move(av_codec_context)) { +FfmpegVideoDecoder::FfmpegVideoDecoder(AvCodecContextPtr av_codec_context) + : FfmpegDecoderBase(std::move(av_codec_context)) { DCHECK(context()); } FfmpegVideoDecoder::~FfmpegVideoDecoder() {} -int FfmpegVideoDecoder::Decode( - const AVPacket& av_packet, - const ffmpeg::AvFramePtr& av_frame_ptr, - PayloadAllocator* allocator, - bool* frame_decoded_out) { +int FfmpegVideoDecoder::Decode(const AVPacket& av_packet, + const ffmpeg::AvFramePtr& av_frame_ptr, + PayloadAllocator* allocator, + bool* frame_decoded_out) { DCHECK(av_frame_ptr); DCHECK(allocator); DCHECK(frame_decoded_out); @@ -27,28 +26,19 @@ int frame_decoded = 0; int input_bytes_used = avcodec_decode_video2( - context().get(), - av_frame_ptr.get(), - &frame_decoded, - &av_packet); + context().get(), av_frame_ptr.get(), &frame_decoded, &av_packet); *frame_decoded_out = frame_decoded != 0; return input_bytes_used; } - -PacketPtr FfmpegVideoDecoder::CreateOutputPacket( - const AVFrame& av_frame, - PayloadAllocator* allocator) { +PacketPtr FfmpegVideoDecoder::CreateOutputPacket(const AVFrame& av_frame, + PayloadAllocator* allocator) { DCHECK(allocator); // End of stream is indicated when we're draining and produce no packet. // TODO(dalesat): This is just a copy of the audio version. - return Packet::Create( - av_frame.pts, - false, - packet_size_, - av_frame.data[0], - allocator); + return Packet::Create(av_frame.pts, false, packet_size_, av_frame.data[0], + allocator); } PacketPtr FfmpegVideoDecoder::CreateOutputEndOfStreamPacket() { @@ -66,12 +56,12 @@ // be sure to avoid using context(). // TODO(dalesat): Not sure why/if this is needed. - //int result = av_image_check_size( + // int result = av_image_check_size( // av_codec_context->width, // av_codec_context->height, // 0, // NULL); - //if (result < 0) { + // if (result < 0) { // DCHECK(false) << "av_image_check_size failed"; // return result; //} @@ -81,10 +71,10 @@ std::max(av_codec_context->width, av_codec_context->coded_width); int coded_height = std::max(av_codec_context->height, av_codec_context->coded_height); - DCHECK_EQ(coded_width, av_codec_context->coded_width) << - "coded width is less than width"; - DCHECK_EQ(coded_height, av_codec_context->coded_height) << - "coded height is less than height"; + DCHECK_EQ(coded_width, av_codec_context->coded_width) + << "coded width is less than width"; + DCHECK_EQ(coded_height, av_codec_context->coded_height) + << "coded height is less than height"; // TODO(dalesat): Fill in av_frame->data and av_frame->data for each plane. @@ -94,20 +84,20 @@ av_frame->reordered_opaque = av_codec_context->reordered_opaque; av_frame->buf[0] = av_buffer_create( - av_frame->data[0], // Because this is the first chunk in the buffer. - 0, // TODO(dalesat): Provide this. + av_frame->data[0], // Because this is the first chunk in the buffer. + 0, // TODO(dalesat): Provide this. ReleaseBufferForAvFrame, - nullptr, // opaque - 0); // flags + nullptr, // opaque + 0); // flags return 0; } -void FfmpegVideoDecoder::ReleaseBufferForAvFrame( - void* opaque, uint8_t* buffer) { +void FfmpegVideoDecoder::ReleaseBufferForAvFrame(void* opaque, + uint8_t* buffer) { // Nothing to do. // TODO(dalesat): Can we get rid of this method altogether? } -} // namespace media -} // namespace mojo +} // namespace media +} // namespace mojo
diff --git a/services/media/framework_ffmpeg/ffmpeg_video_decoder.h b/services/media/framework_ffmpeg/ffmpeg_video_decoder.h index 3d3d4f7..dc85392 100644 --- a/services/media/framework_ffmpeg/ffmpeg_video_decoder.h +++ b/services/media/framework_ffmpeg/ffmpeg_video_decoder.h
@@ -20,24 +20,21 @@ protected: // FfmpegDecoderBase overrides. - int Decode( - const AVPacket& av_packet, - const ffmpeg::AvFramePtr& av_frame_ptr, - PayloadAllocator* allocator, - bool* frame_decoded_out) override; + int Decode(const AVPacket& av_packet, + const ffmpeg::AvFramePtr& av_frame_ptr, + PayloadAllocator* allocator, + bool* frame_decoded_out) override; - PacketPtr CreateOutputPacket( - const AVFrame& av_frame, - PayloadAllocator* allocator) override; + PacketPtr CreateOutputPacket(const AVFrame& av_frame, + PayloadAllocator* allocator) override; PacketPtr CreateOutputEndOfStreamPacket() override; private: // Callback used by the ffmpeg decoder to acquire a buffer. - static int AllocateBufferForAvFrame( - AVCodecContext* av_codec_context, - AVFrame* av_frame, - int flags); + static int AllocateBufferForAvFrame(AVCodecContext* av_codec_context, + AVFrame* av_frame, + int flags); // Callback used by the ffmpeg decoder to release a buffer. static void ReleaseBufferForAvFrame(void* opaque, uint8_t* buffer); @@ -48,10 +45,10 @@ // This is used to verify that an allocated buffer is being used as expected // by ffmpeg avcodec_decode_audio4. AllocateBufferForAvFrame sets it. - //void* packet_buffer_; + // void* packet_buffer_; }; } // namespace media } // namespace mojo -#endif // SERVICES_MEDIA_FRAMEWORK_FFMPEG_FFMPEG_VIDEO_DECODER_H_ +#endif // SERVICES_MEDIA_FRAMEWORK_FFMPEG_FFMPEG_VIDEO_DECODER_H_
diff --git a/services/media/framework_mojo/mojo_allocator.h b/services/media/framework_mojo/mojo_allocator.h index 6a0fda4..75a8371 100644 --- a/services/media/framework_mojo/mojo_allocator.h +++ b/services/media/framework_mojo/mojo_allocator.h
@@ -12,9 +12,8 @@ namespace media { // Just like SharedMediaBufferAllocator but implements PayloadAllocator. -class MojoAllocator : - public SharedMediaBufferAllocator, - public PayloadAllocator { +class MojoAllocator : public SharedMediaBufferAllocator, + public PayloadAllocator { public: ~MojoAllocator() override; @@ -27,4 +26,4 @@ } // namespace media } // namespace mojo -#endif // SERVICES_MEDIA_FRAMEWORK_MOJO_MOJO_ALLOCATOR_H_ +#endif // SERVICES_MEDIA_FRAMEWORK_MOJO_MOJO_ALLOCATOR_H_
diff --git a/services/media/framework_mojo/mojo_consumer.cc b/services/media/framework_mojo/mojo_consumer.cc index 37f3032..5aa8567 100644 --- a/services/media/framework_mojo/mojo_consumer.cc +++ b/services/media/framework_mojo/mojo_consumer.cc
@@ -35,23 +35,18 @@ flush_requested_callback_ = callback; } -void MojoConsumer::SetBuffer( - ScopedSharedBufferHandle buffer, - const SetBufferCallback& callback) { +void MojoConsumer::SetBuffer(ScopedSharedBufferHandle buffer, + const SetBufferCallback& callback) { buffer_.InitFromHandle(buffer.Pass()); callback.Run(); } -void MojoConsumer::SendPacket( - MediaPacketPtr media_packet, - const SendPacketCallback& callback) { +void MojoConsumer::SendPacket(MediaPacketPtr media_packet, + const SendPacketCallback& callback) { DCHECK(media_packet); DCHECK(supply_callback_); - supply_callback_(PacketImpl::Create( - media_packet.Pass(), - callback, - task_runner_, - buffer_)); + supply_callback_( + PacketImpl::Create(media_packet.Pass(), callback, task_runner_, buffer_)); } void MojoConsumer::Prime(const PrimeCallback& callback) { @@ -90,17 +85,16 @@ MediaPacketPtr media_packet, const SendPacketCallback& callback, scoped_refptr<base::SingleThreadTaskRunner> task_runner, - const MappedSharedBuffer& buffer) : - Packet( - media_packet->pts, - media_packet->end_of_stream, - media_packet->payload->length, - media_packet->payload->length == 0 ? - nullptr : - buffer.PtrFromOffset(media_packet->payload->offset)), - media_packet_(media_packet.Pass()), - callback_(callback), - task_runner_(task_runner) {} + const MappedSharedBuffer& buffer) + : Packet(media_packet->pts, + media_packet->end_of_stream, + media_packet->payload->length, + media_packet->payload->length == 0 + ? nullptr + : buffer.PtrFromOffset(media_packet->payload->offset)), + media_packet_(media_packet.Pass()), + callback_(callback), + task_runner_(task_runner) {} MojoConsumer::PacketImpl::~PacketImpl() {}
diff --git a/services/media/framework_mojo/mojo_consumer.h b/services/media/framework_mojo/mojo_consumer.h index c464373..44ffc8e 100644 --- a/services/media/framework_mojo/mojo_consumer.h +++ b/services/media/framework_mojo/mojo_consumer.h
@@ -5,7 +5,6 @@ #ifndef SERVICES_MEDIA_FRAMEWORK_MOJO_MOJO_CONSUMER_H_ #define SERVICES_MEDIA_FRAMEWORK_MOJO_MOJO_CONSUMER_H_ - #include "base/single_thread_task_runner.h" #include "base/task_runner.h" #include "mojo/common/binding_set.h" @@ -50,12 +49,11 @@ void SetFlushRequestedCallback(const FlushRequestedCallback& callback); // MediaConsumer implementation. - void SetBuffer( - ScopedSharedBufferHandle buffer, - const SetBufferCallback& callback) override; + void SetBuffer(ScopedSharedBufferHandle buffer, + const SetBufferCallback& callback) override; - void SendPacket(MediaPacketPtr packet, const SendPacketCallback& callback) - override; + void SendPacket(MediaPacketPtr packet, + const SendPacketCallback& callback) override; void Prime(const PrimeCallback& callback) override; @@ -81,22 +79,18 @@ const SendPacketCallback& callback, scoped_refptr<base::SingleThreadTaskRunner> task_runner, const MappedSharedBuffer& buffer) { - return PacketPtr(new PacketImpl( - media_packet.Pass(), - callback, - task_runner, - buffer)); + return PacketPtr( + new PacketImpl(media_packet.Pass(), callback, task_runner, buffer)); } protected: void Release() override; private: - PacketImpl( - MediaPacketPtr media_packet, - const SendPacketCallback& callback, - scoped_refptr<base::SingleThreadTaskRunner> task_runner, - const MappedSharedBuffer& buffer); + PacketImpl(MediaPacketPtr media_packet, + const SendPacketCallback& callback, + scoped_refptr<base::SingleThreadTaskRunner> task_runner, + const MappedSharedBuffer& buffer); ~PacketImpl() override;
diff --git a/services/media/framework_mojo/mojo_formatting.cc b/services/media/framework_mojo/mojo_formatting.cc index ad5c02a..fdab5a0 100644 --- a/services/media/framework_mojo/mojo_formatting.cc +++ b/services/media/framework_mojo/mojo_formatting.cc
@@ -7,7 +7,7 @@ namespace mojo { namespace media { -template<typename T> +template <typename T> std::ostream& operator<<(std::ostream& os, const InterfacePtr<T>& value) { if (!value.is_bound()) { return os << "<not bound>" << std::endl; @@ -16,9 +16,8 @@ } } -std::ostream& operator<<( - std::ostream& os, - const MediaSourceStreamDescriptorPtr& value) { +std::ostream& operator<<(std::ostream& os, + const MediaSourceStreamDescriptorPtr& value) { if (!value) { return os << "<nullptr>" << std::endl; } else { @@ -28,8 +27,8 @@ os << indent; os << begl << "uint32_t index: " << int(value->index) << std::endl; os << begl << "MediaTypePtr media_type: " << value->media_type; - os << begl << "MediaTypePtr original_media_type: " << - value->original_media_type; + os << begl + << "MediaTypePtr original_media_type: " << value->original_media_type; return os << outdent; } @@ -41,8 +40,9 @@ } os << indent; - os << begl << "MediaTypeScheme scheme: " << - StringFromMediaTypeScheme(value->scheme) << std::endl; + os << begl + << "MediaTypeScheme scheme: " << StringFromMediaTypeScheme(value->scheme) + << std::endl; os << begl << "MediaTypeDetailsPtr details: " << value->details; return os << outdent; } @@ -55,8 +55,9 @@ } os << indent; - os << begl << "MediaTypeScheme scheme: " << - StringFromMediaTypeScheme(value->scheme) << std::endl; + os << begl + << "MediaTypeScheme scheme: " << StringFromMediaTypeScheme(value->scheme) + << std::endl; os << begl << "MediaTypeSetDetailsPtr details: " << value->details; return os << outdent; } @@ -64,7 +65,7 @@ std::ostream& operator<<(std::ostream& os, const MediaTypeDetailsPtr& value) { if (!value) { return os << "<nullptr>" << std::endl; - } else if (value->has_unknown_tag()) { + } else if (value->has_unknown_tag()) { return os << "<empty>" << std::endl; } else { os << std::endl; @@ -72,31 +73,31 @@ os << indent; if (value->is_multiplexed()) { - return os << begl << "MultiplexedMediaTypeDetailsPtr* multiplexed: " << - value->get_multiplexed() << outdent; + return os << begl << "MultiplexedMediaTypeDetailsPtr* multiplexed: " + << value->get_multiplexed() << outdent; } if (value->is_lpcm()) { - return os << begl << "LpcmMediaTypeDetailsPtr* lpcm: " << - value->get_lpcm() << outdent; + return os << begl << "LpcmMediaTypeDetailsPtr* lpcm: " << value->get_lpcm() + << outdent; } if (value->is_compressed_audio()) { - return os << begl << - "CompressedAudiomMediaTypeDetailsPtr* compressed_audio: " << - value->get_compressed_audio() << outdent; + return os << begl + << "CompressedAudiomMediaTypeDetailsPtr* compressed_audio: " + << value->get_compressed_audio() << outdent; } if (value->is_video()) { - return os << begl << "VideoMediaTypeDetailsPtr* video: " << - value->get_video() << outdent; + return os << begl + << "VideoMediaTypeDetailsPtr* video: " << value->get_video() + << outdent; } return os << begl << "UNKNOWN TAG" << std::endl << outdent; } -std::ostream& operator<<( - std::ostream& os, - const MediaTypeSetDetailsPtr& value) { +std::ostream& operator<<(std::ostream& os, + const MediaTypeSetDetailsPtr& value) { if (!value) { return os << "<nullptr>" << std::endl; - } else if (value->has_unknown_tag()) { + } else if (value->has_unknown_tag()) { return os << "<empty>" << std::endl; } else { os << std::endl; @@ -104,28 +105,29 @@ os << indent; if (value->is_multiplexed()) { - return os << begl << "MultiplexedMediaTypeSetDetailsPtr* multiplexed: " << - value->get_multiplexed() << outdent; + return os << begl << "MultiplexedMediaTypeSetDetailsPtr* multiplexed: " + << value->get_multiplexed() << outdent; } if (value->is_lpcm()) { - return os << begl << "LpcmMediaTypeSetDetailsPtr* lpcm: " << - value->get_lpcm() << outdent; + return os << begl + << "LpcmMediaTypeSetDetailsPtr* lpcm: " << value->get_lpcm() + << outdent; } if (value->is_compressed_audio()) { - return os << begl << - "CompressedAudioMediaTypeSetDetailsPtr* compressed_audio: " << - value->get_compressed_audio() << outdent; + return os << begl + << "CompressedAudioMediaTypeSetDetailsPtr* compressed_audio: " + << value->get_compressed_audio() << outdent; } if (value->is_video()) { - return os << begl << "VideoMediaTypeSetDetailsPtr* video: " << - value->get_video() << outdent; + return os << begl + << "VideoMediaTypeSetDetailsPtr* video: " << value->get_video() + << outdent; } return os << begl << "UNKNOWN TAG" << std::endl << outdent; } -std::ostream& operator<<( - std::ostream& os, - const MultiplexedMediaTypeDetailsPtr& value) { +std::ostream& operator<<(std::ostream& os, + const MultiplexedMediaTypeDetailsPtr& value) { if (!value) { return os << "<nullptr>" << std::endl; } else { @@ -134,14 +136,13 @@ os << indent; os << begl << "MediaTypePtr multiplex_type: " << value->multiplex_type; - os << begl << "Array<MediaTypePtr> substream_types: " << - value->substream_types; + os << begl + << "Array<MediaTypePtr> substream_types: " << value->substream_types; return os << outdent; } -std::ostream& operator<<( - std::ostream& os, - const MultiplexedMediaTypeSetDetailsPtr& value) { +std::ostream& operator<<(std::ostream& os, + const MultiplexedMediaTypeSetDetailsPtr& value) { if (!value) { return os << "<nullptr>" << std::endl; } else { @@ -149,16 +150,15 @@ } os << indent; - os << begl << "MediaTypeSetPtr multiplex_type_set: " << - value->multiplex_type_set; - os << begl << "Array<MediaTypeSetPtr> substream_type_sets: " << - value->substream_type_sets; + os << begl + << "MediaTypeSetPtr multiplex_type_set: " << value->multiplex_type_set; + os << begl << "Array<MediaTypeSetPtr> substream_type_sets: " + << value->substream_type_sets; return os << outdent; } -std::ostream& operator<<( - std::ostream& os, - const LpcmMediaTypeDetailsPtr& value) { +std::ostream& operator<<(std::ostream& os, + const LpcmMediaTypeDetailsPtr& value) { if (!value) { return os << "<nullptr>" << std::endl; } else { @@ -166,17 +166,16 @@ } os << indent; - os << begl << "LpcmSampleFormat sample_format: " << - StringFromLpcmSampleFormat(value->sample_format) << std::endl; + os << begl << "LpcmSampleFormat sample_format: " + << StringFromLpcmSampleFormat(value->sample_format) << std::endl; os << begl << "uint32_t channels: " << int(value->channels) << std::endl; - os << begl << "uint32_t frames_per_second: " << value->frames_per_second << - std::endl; + os << begl << "uint32_t frames_per_second: " << value->frames_per_second + << std::endl; return os << outdent; } -std::ostream& operator<<( - std::ostream& os, - const LpcmMediaTypeSetDetailsPtr& value) { +std::ostream& operator<<(std::ostream& os, + const LpcmMediaTypeSetDetailsPtr& value) { if (!value) { return os << "<nullptr>" << std::endl; } else { @@ -184,22 +183,23 @@ } os << indent; - os << begl << "LpcmSampleFormat sample_format: " << - StringFromLpcmSampleFormat(value->sample_format) << std::endl; - os << begl << "uint32_t min_channels: " << int(value->min_channels) << - std::endl; - os << begl << "uint32_t max_channels: " << int(value->max_channels) << - std::endl; - os << begl << "uint32_t min_frames_per_second: " << - value->min_frames_per_second << std::endl; - os << begl << "uint32_t max_cframes_per_second: " << - value->max_frames_per_second << std::endl; + os << begl << "LpcmSampleFormat sample_format: " + << StringFromLpcmSampleFormat(value->sample_format) << std::endl; + os << begl << "uint32_t min_channels: " << int(value->min_channels) + << std::endl; + os << begl << "uint32_t max_channels: " << int(value->max_channels) + << std::endl; + os << begl + << "uint32_t min_frames_per_second: " << value->min_frames_per_second + << std::endl; + os << begl + << "uint32_t max_cframes_per_second: " << value->max_frames_per_second + << std::endl; return os << outdent; } -std::ostream& operator<<( - std::ostream& os, - const CompressedAudioMediaTypeDetailsPtr& value) { +std::ostream& operator<<(std::ostream& os, + const CompressedAudioMediaTypeDetailsPtr& value) { if (!value) { return os << "<nullptr>" << std::endl; } else { @@ -207,19 +207,19 @@ } os << indent; - os << begl << "AudioEncoding encoding: " << - StringFromAudioEncoding(value->encoding) << std::endl; - os << begl << "LpcmSampleFormat sample_format: " << - StringFromLpcmSampleFormat(value->sample_format) << std::endl; + os << begl + << "AudioEncoding encoding: " << StringFromAudioEncoding(value->encoding) + << std::endl; + os << begl << "LpcmSampleFormat sample_format: " + << StringFromLpcmSampleFormat(value->sample_format) << std::endl; os << begl << "uint32_t channels: " << int(value->channels) << std::endl; - os << begl << "uint32_t frames_per_second: " << value->frames_per_second << - std::endl; + os << begl << "uint32_t frames_per_second: " << value->frames_per_second + << std::endl; return os << outdent; } -std::ostream& operator<<( - std::ostream& os, - const CompressedAudioMediaTypeSetDetailsPtr& value) { +std::ostream& operator<<(std::ostream& os, + const CompressedAudioMediaTypeSetDetailsPtr& value) { if (!value) { return os << "<nullptr>" << std::endl; } else { @@ -227,24 +227,26 @@ } os << indent; - os << begl << "AudioEncoding encoding: " << - StringFromAudioEncoding(value->encoding) << std::endl; - os << begl << "LpcmSampleFormat sample_format: " << - StringFromLpcmSampleFormat(value->sample_format) << std::endl; - os << begl << "uint32_t min_channels: " << int(value->min_channels) << - std::endl; - os << begl << "uint32_t max_channels: " << int(value->max_channels) << - std::endl; - os << begl << "uint32_t min_frames_per_second: " << - value->min_frames_per_second << std::endl; - os << begl << "uint32_t max_cframes_per_second: " << - value->max_frames_per_second << std::endl; + os << begl + << "AudioEncoding encoding: " << StringFromAudioEncoding(value->encoding) + << std::endl; + os << begl << "LpcmSampleFormat sample_format: " + << StringFromLpcmSampleFormat(value->sample_format) << std::endl; + os << begl << "uint32_t min_channels: " << int(value->min_channels) + << std::endl; + os << begl << "uint32_t max_channels: " << int(value->max_channels) + << std::endl; + os << begl + << "uint32_t min_frames_per_second: " << value->min_frames_per_second + << std::endl; + os << begl + << "uint32_t max_cframes_per_second: " << value->max_frames_per_second + << std::endl; return os << outdent; } -std::ostream& operator<<( - std::ostream& os, - const VideoMediaTypeDetailsPtr& value) { +std::ostream& operator<<(std::ostream& os, + const VideoMediaTypeDetailsPtr& value) { if (!value) { return os << "<nullptr>" << std::endl; } else { @@ -252,11 +254,12 @@ } os << indent; - os << begl << "VideoEncoding encoding: " << - StringFromVideoEncoding(value->encoding) << std::endl; + os << begl + << "VideoEncoding encoding: " << StringFromVideoEncoding(value->encoding) + << std::endl; os << begl << "VideoProfile profile: " << value->profile << std::endl; - os << begl << "PixelFormat pixel_format: " << - value->pixel_format << std::endl; + os << begl << "PixelFormat pixel_format: " << value->pixel_format + << std::endl; os << begl << "ColorSpace color_space: " << value->color_space << std::endl; os << begl << "uint32_t width: " << value->width << std::endl; os << begl << "uint32_t height: " << value->height << std::endl; @@ -265,9 +268,8 @@ return os << outdent; } -std::ostream& operator<<( - std::ostream& os, - const VideoMediaTypeSetDetailsPtr& value) { +std::ostream& operator<<(std::ostream& os, + const VideoMediaTypeSetDetailsPtr& value) { if (!value) { return os << "<nullptr>" << std::endl; } else { @@ -275,8 +277,9 @@ } os << indent; - os << begl << "VideoEncoding encoding: " << - StringFromVideoEncoding(value->encoding) << std::endl; + os << begl + << "VideoEncoding encoding: " << StringFromVideoEncoding(value->encoding) + << std::endl; os << begl << "uint32_t min_width: " << value->min_width << std::endl; os << begl << "uint32_t max_width: " << value->max_width << std::endl; os << begl << "uint32_t min_height: " << value->min_height << std::endl; @@ -284,9 +287,7 @@ return os << outdent; } -std::ostream& operator<<( - std::ostream& os, - const TimelineQuadPtr& value) { +std::ostream& operator<<(std::ostream& os, const TimelineQuadPtr& value) { if (!value) { return os << "<nullptr>" << std::endl; } else { @@ -294,20 +295,16 @@ } os << indent; - os << begl << "int64 reference_offset: " - << value->reference_offset << std::endl; - os << begl << "int64 target_offset: " - << value->target_offset << std::endl; - os << begl << "int32 reference_delta: " - << value->reference_delta << std::endl; - os << begl << "uint32 target_delta: " - << value->target_delta << std::endl; + os << begl << "int64 reference_offset: " << value->reference_offset + << std::endl; + os << begl << "int64 target_offset: " << value->target_offset << std::endl; + os << begl << "int32 reference_delta: " << value->reference_delta + << std::endl; + os << begl << "uint32 target_delta: " << value->target_delta << std::endl; return os << outdent; } -std::ostream& operator<<( - std::ostream& os, - const TimelineTransformPtr& value) { +std::ostream& operator<<(std::ostream& os, const TimelineTransformPtr& value) { if (!value) { return os << "<nullptr>" << std::endl; } else { @@ -316,10 +313,10 @@ os << indent; os << begl << "TimelineQuad quad: " << value->quad; - os << begl << "uint32 reference_timeline_id: " - << value->reference_timeline_id << std::endl; - os << begl << "uint32 target_timeline_id: " - << value->target_timeline_id << std::endl; + os << begl << "uint32 reference_timeline_id: " << value->reference_timeline_id + << std::endl; + os << begl << "uint32 target_timeline_id: " << value->target_timeline_id + << std::endl; return os << outdent; } @@ -415,5 +412,5 @@ return "UNKNOWN MEDIA STATE"; } -} // namespace media -} // namespace mojo +} // namespace media +} // namespace mojo
diff --git a/services/media/framework_mojo/mojo_formatting.h b/services/media/framework_mojo/mojo_formatting.h index 2755a8b..e0270a1 100644 --- a/services/media/framework_mojo/mojo_formatting.h +++ b/services/media/framework_mojo/mojo_formatting.h
@@ -26,15 +26,15 @@ // The following overloads add newlines. -template<typename T> +template <typename T> std::ostream& operator<<(std::ostream& os, const InterfacePtr<T>& value); -template<typename T> +template <typename T> std::ostream& operator<<(std::ostream& os, const Array<T>& value) { if (!value) { return os << "<nullptr>" << std::endl; } else if (value.size() == 0) { - return os << "<empty>" << std::endl; + return os << "<empty>" << std::endl; } else { os << std::endl; } @@ -51,41 +51,28 @@ std::ostream& operator<<(std::ostream& os, const MediaTypeSetPtr& value); std::ostream& operator<<(std::ostream& os, const MediaTypeDetailsPtr& value); std::ostream& operator<<(std::ostream& os, const MediaTypeSetDetailsPtr& value); -std::ostream& operator<<( - std::ostream& os, - const MultiplexedMediaTypeDetailsPtr& value); -std::ostream& operator<<( - std::ostream& os, - const MultiplexedMediaTypeSetDetailsPtr& value); -std::ostream& operator<<( - std::ostream& os, - const LpcmMediaTypeDetailsPtr& value); -std::ostream& operator<<( - std::ostream& os, - const LpcmMediaTypeSetDetailsPtr& value); -std::ostream& operator<<( - std::ostream& os, - const CompressedAudioMediaTypeDetailsPtr& value); -std::ostream& operator<<( - std::ostream& os, - const CompressedAudioMediaTypeSetDetailsPtr& value); -std::ostream& operator<<( - std::ostream& os, - const VideoMediaTypeDetailsPtr& value); -std::ostream& operator<<( - std::ostream& os, - const VideoMediaTypeSetDetailsPtr& value); -std::ostream& operator<<( - std::ostream& os, - const MediaSourceStreamDescriptorPtr& value); -std::ostream& operator<<( - std::ostream& os, - const TimelineQuadPtr& value); -std::ostream& operator<<( - std::ostream& os, - const TimelineTransformPtr& value); +std::ostream& operator<<(std::ostream& os, + const MultiplexedMediaTypeDetailsPtr& value); +std::ostream& operator<<(std::ostream& os, + const MultiplexedMediaTypeSetDetailsPtr& value); +std::ostream& operator<<(std::ostream& os, + const LpcmMediaTypeDetailsPtr& value); +std::ostream& operator<<(std::ostream& os, + const LpcmMediaTypeSetDetailsPtr& value); +std::ostream& operator<<(std::ostream& os, + const CompressedAudioMediaTypeDetailsPtr& value); +std::ostream& operator<<(std::ostream& os, + const CompressedAudioMediaTypeSetDetailsPtr& value); +std::ostream& operator<<(std::ostream& os, + const VideoMediaTypeDetailsPtr& value); +std::ostream& operator<<(std::ostream& os, + const VideoMediaTypeSetDetailsPtr& value); +std::ostream& operator<<(std::ostream& os, + const MediaSourceStreamDescriptorPtr& value); +std::ostream& operator<<(std::ostream& os, const TimelineQuadPtr& value); +std::ostream& operator<<(std::ostream& os, const TimelineTransformPtr& value); -} // namespace media -} // namespace mojo +} // namespace media +} // namespace mojo -#endif // SERVICES_MEDIA_FRAMEWORK_MOJO_MOJO_FORMATTING_H_ +#endif // SERVICES_MEDIA_FRAMEWORK_MOJO_MOJO_FORMATTING_H_
diff --git a/services/media/framework_mojo/mojo_producer.cc b/services/media/framework_mojo/mojo_producer.cc index a876395..e54e651 100644 --- a/services/media/framework_mojo/mojo_producer.cc +++ b/services/media/framework_mojo/mojo_producer.cc
@@ -30,9 +30,9 @@ { base::AutoLock lock(lock_); max_pushes_outstanding_ = 10; // TODO(dalesat): Made up! - demand = current_pushes_outstanding_ < max_pushes_outstanding_ ? - Demand::kPositive : - Demand::kNegative; + demand = current_pushes_outstanding_ < max_pushes_outstanding_ + ? Demand::kPositive + : Demand::kNegative; } DCHECK(demand_callback_); @@ -40,9 +40,7 @@ SetState(MediaState::PAUSED); DCHECK(consumer_.is_bound()); - consumer_->Prime([this, callback]() { - callback.Run(); - }); + consumer_->Prime([this, callback]() { callback.Run(); }); } void MojoProducer::FlushConnection(const FlushConnectionCallback& callback) { @@ -60,8 +58,7 @@ end_of_stream_ = false; } -void MojoProducer::SetStatusCallback( - const StatusCallback& callback) { +void MojoProducer::SetStatusCallback(const StatusCallback& callback) { status_callback_ = callback; } @@ -105,25 +102,23 @@ demand = Demand::kNegative; max_pushes_outstanding_ = 0; } else { - demand = current_pushes_outstanding_ < max_pushes_outstanding_ ? - Demand::kPositive : - Demand::kNegative; + demand = current_pushes_outstanding_ < max_pushes_outstanding_ + ? Demand::kPositive + : Demand::kNegative; } } MediaPacketPtr media_packet = CreateMediaPacket(packet); - task_runner_->PostTask(FROM_HERE, base::Bind( - &MojoProducer::SendPacket, - base::Unretained(this), - packet.release(), - base::Passed(media_packet.Pass()))); + task_runner_->PostTask( + FROM_HERE, + base::Bind(&MojoProducer::SendPacket, base::Unretained(this), + packet.release(), base::Passed(media_packet.Pass()))); return demand; } -void MojoProducer::Connect( - InterfaceHandle<MediaConsumer> consumer, - const ConnectCallback& callback) { +void MojoProducer::Connect(InterfaceHandle<MediaConsumer> consumer, + const ConnectCallback& callback) { DCHECK(consumer); consumer_ = MediaConsumerPtr::Create(std::move(consumer)); @@ -132,11 +127,8 @@ mojo_allocator_.InitNew(256 * 1024); // TODO(dalesat): Made up! } - consumer_->SetBuffer( - mojo_allocator_.GetDuplicateHandle(), - [callback]() { - callback.Run(); - }); + consumer_->SetBuffer(mojo_allocator_.GetDuplicateHandle(), + [callback]() { callback.Run(); }); } void MojoProducer::Disconnect() { @@ -146,29 +138,28 @@ consumer_.reset(); } -void MojoProducer::SendPacket( - Packet* packet_raw_ptr, - MediaPacketPtr media_packet) { +void MojoProducer::SendPacket(Packet* packet_raw_ptr, + MediaPacketPtr media_packet) { consumer_->SendPacket( - media_packet.Pass(), - [this, packet_raw_ptr](MediaConsumer::SendResult send_result) { - PacketPtr packet = PacketPtr(packet_raw_ptr); - Demand demand; + media_packet.Pass(), + [this, packet_raw_ptr](MediaConsumer::SendResult send_result) { + PacketPtr packet = PacketPtr(packet_raw_ptr); + Demand demand; - { - base::AutoLock lock(lock_); - demand = --current_pushes_outstanding_ < max_pushes_outstanding_ ? - Demand::kPositive : - Demand::kNegative; - } + { + base::AutoLock lock(lock_); + demand = --current_pushes_outstanding_ < max_pushes_outstanding_ + ? Demand::kPositive + : Demand::kNegative; + } - DCHECK(demand_callback_); - demand_callback_(demand); + DCHECK(demand_callback_); + demand_callback_(demand); - if (end_of_stream_ && packet->end_of_stream()) { - SetState(MediaState::ENDED); - } - }); + if (end_of_stream_ && packet->end_of_stream()) { + SetState(MediaState::ENDED); + } + }); } void MojoProducer::SetState(MediaState state) { @@ -180,13 +171,13 @@ } } -MediaPacketPtr MojoProducer::CreateMediaPacket( - const PacketPtr& packet) { +MediaPacketPtr MojoProducer::CreateMediaPacket(const PacketPtr& packet) { DCHECK(packet); MediaPacketRegionPtr region = MediaPacketRegion::New(); - region->offset = packet->size() == 0 ? 0 : - mojo_allocator_.OffsetFromPtr(packet->payload()); + region->offset = packet->size() == 0 + ? 0 + : mojo_allocator_.OffsetFromPtr(packet->payload()); region->length = packet->size(); MediaPacketPtr media_packet = MediaPacket::New();
diff --git a/services/media/framework_mojo/mojo_producer.h b/services/media/framework_mojo/mojo_producer.h index 5679b7c..ba37aab 100644 --- a/services/media/framework_mojo/mojo_producer.h +++ b/services/media/framework_mojo/mojo_producer.h
@@ -55,9 +55,8 @@ Demand SupplyPacket(PacketPtr packet) override; // MediaProducer implementation. - void Connect( - InterfaceHandle<MediaConsumer> consumer, - const ConnectCallback& callback) override; + void Connect(InterfaceHandle<MediaConsumer> consumer, + const ConnectCallback& callback) override; void Disconnect() override; @@ -66,9 +65,7 @@ // Sends a packet to the consumer. // TODO(dalesat): Don't use a raw pointer, if possible. - void SendPacket( - Packet* packet_raw_ptr, - MediaPacketPtr media_packet); + void SendPacket(Packet* packet_raw_ptr, MediaPacketPtr media_packet); // Sets the current state and calls the registered callback, if there is one. void SetState(MediaState state); @@ -85,8 +82,8 @@ mutable base::Lock lock_; // THE FIELDS BELOW SHOULD ONLY BE ACCESSED WITH lock_ TAKEN. - MediaState state_= MediaState::UNPREPARED; - bool end_of_stream_= false; + MediaState state_ = MediaState::UNPREPARED; + bool end_of_stream_ = false; DemandCallback demand_callback_; scoped_refptr<base::SingleThreadTaskRunner> task_runner_; int64_t first_pts_since_flush_ = Packet::kUnknownPts;
diff --git a/services/media/framework_mojo/mojo_pull_mode_producer.cc b/services/media/framework_mojo/mojo_pull_mode_producer.cc index b2c7dc8..f953aa5 100644 --- a/services/media/framework_mojo/mojo_pull_mode_producer.cc +++ b/services/media/framework_mojo/mojo_pull_mode_producer.cc
@@ -8,11 +8,11 @@ namespace mojo { namespace media { -MojoPullModeProducer::MojoPullModeProducer() : - state_(MediaState::UNPREPARED), - demand_(Demand::kNegative), - pts_(0), - cached_packet_(nullptr) {} +MojoPullModeProducer::MojoPullModeProducer() + : state_(MediaState::UNPREPARED), + demand_(Demand::kNegative), + pts_(0), + cached_packet_(nullptr) {} MojoPullModeProducer::~MojoPullModeProducer() { base::AutoLock lock(lock_); @@ -25,7 +25,7 @@ void MojoPullModeProducer::GetBuffer(const GetBufferCallback& callback) { if (!mojo_allocator_.initialized()) { - mojo_allocator_.InitNew(256 * 1024); // TODO(dalesat): Made up! + mojo_allocator_.InitNew(256 * 1024); // TODO(dalesat): Made up! } { @@ -42,9 +42,8 @@ demand_callback_(Demand::kPositive); } -void MojoPullModeProducer::PullPacket( - MediaPacketPtr to_release, - const PullPacketCallback& callback) { +void MojoPullModeProducer::PullPacket(MediaPacketPtr to_release, + const PullPacketCallback& callback) { if (to_release) { // The client has piggy-backed a release on this pull request. ReleasePacket(to_release.Pass()); @@ -78,8 +77,8 @@ { base::AutoLock lock(lock_); uint64_t size = to_release->payload ? to_release->payload->length : 0; - void* payload = size == 0 ? nullptr : - mojo_allocator_.PtrFromOffset(to_release->payload->offset); + void* payload = size == 0 ? nullptr : mojo_allocator_.PtrFromOffset( + to_release->payload->offset); for (auto iterator = unreleased_packets_.begin(); true; ++iterator) { if (iterator == unreleased_packets_.end()) { @@ -155,9 +154,7 @@ if (state_ == MediaState::ENDED) { // At end-of-stream. Respond with empty end-of-stream packet. - HandlePullWithPacketUnsafe( - callback, - Packet::CreateEndOfStream(pts_)); + HandlePullWithPacketUnsafe(callback, Packet::CreateEndOfStream(pts_)); return true; } @@ -198,5 +195,5 @@ return media_packet.Pass(); } -} // namespace media -} // namespace mojo +} // namespace media +} // namespace mojo
diff --git a/services/media/framework_mojo/mojo_pull_mode_producer.h b/services/media/framework_mojo/mojo_pull_mode_producer.h index 8ba6fc6..0d27a74 100644 --- a/services/media/framework_mojo/mojo_pull_mode_producer.h +++ b/services/media/framework_mojo/mojo_pull_mode_producer.h
@@ -18,9 +18,7 @@ namespace media { // Implements MediaPullModeProducer to forward a stream across mojo. -class MojoPullModeProducer : - public MediaPullModeProducer, - public ActiveSink { +class MojoPullModeProducer : public MediaPullModeProducer, public ActiveSink { public: static std::shared_ptr<MojoPullModeProducer> Create() { return std::shared_ptr<MojoPullModeProducer>(new MojoPullModeProducer()); @@ -34,9 +32,8 @@ // MediaPullModeProducer implementation. void GetBuffer(const GetBufferCallback& callback) override; - void PullPacket( - MediaPacketPtr to_release, - const PullPacketCallback& callback) override; + void PullPacket(MediaPacketPtr to_release, + const PullPacketCallback& callback) override; void ReleasePacket(MediaPacketPtr to_release) override; @@ -60,9 +57,8 @@ // Runs the callback with a new MediaPacket created from the given Packet. // MUST BE CALLED WITH lock_ TAKEN. - void HandlePullWithPacketUnsafe( - const PullPacketCallback& callback, - PacketPtr packet); + void HandlePullWithPacketUnsafe(const PullPacketCallback& callback, + PacketPtr packet); // Creates a MediaPacket from a Packet. MediaPacketPtr CreateMediaPacket(const PacketPtr& packet);
diff --git a/services/media/framework_mojo/mojo_type_conversions.cc b/services/media/framework_mojo/mojo_type_conversions.cc index 8e38142..50b4b2b 100644 --- a/services/media/framework_mojo/mojo_type_conversions.cc +++ b/services/media/framework_mojo/mojo_type_conversions.cc
@@ -8,8 +8,7 @@ namespace mojo { namespace media { -StreamType::Scheme Convert( - MediaTypeScheme media_type_scheme) { +StreamType::Scheme Convert(MediaTypeScheme media_type_scheme) { switch (media_type_scheme) { case MediaTypeScheme::UNKNOWN: return StreamType::Scheme::kUnknown; @@ -59,8 +58,7 @@ return LpcmStreamType::SampleFormat::kUnknown; } -CompressedAudioStreamType::AudioEncoding Convert( - AudioEncoding audio_encoding) { +CompressedAudioStreamType::AudioEncoding Convert(AudioEncoding audio_encoding) { switch (audio_encoding) { case AudioEncoding::UNKNOWN: return CompressedAudioStreamType::AudioEncoding::kUnknown; @@ -193,8 +191,8 @@ Convert(media_type->details->get_compressed_audio()->sample_format), media_type->details->get_compressed_audio()->channels, media_type->details->get_compressed_audio()->frames_per_second, - Convert(media_type->details->get_compressed_audio()-> - extra_data_base64)); + Convert( + media_type->details->get_compressed_audio()->extra_data_base64)); case MediaTypeScheme::VIDEO: return VideoStreamType::Create( Convert(media_type->details->get_video()->encoding), @@ -235,39 +233,35 @@ switch (media_type_set->scheme) { case MediaTypeScheme::MULTIPLEXED: return MultiplexedStreamTypeSet::Create( - Convert(media_type_set->details->get_multiplexed()-> - multiplex_type_set), - Convert(media_type_set->details->get_multiplexed()-> - substream_type_sets)); + Convert( + media_type_set->details->get_multiplexed()->multiplex_type_set), + Convert( + media_type_set->details->get_multiplexed()->substream_type_sets)); case MediaTypeScheme::LPCM: return LpcmStreamTypeSet::Create( Convert(media_type_set->details->get_lpcm()->sample_format), - Range<uint32_t>( - media_type_set->details->get_lpcm()->min_channels, - media_type_set->details->get_lpcm()->max_channels), + Range<uint32_t>(media_type_set->details->get_lpcm()->min_channels, + media_type_set->details->get_lpcm()->max_channels), Range<uint32_t>( media_type_set->details->get_lpcm()->min_frames_per_second, media_type_set->details->get_lpcm()->max_frames_per_second)); case MediaTypeScheme::COMPRESSED_AUDIO: return CompressedAudioStreamTypeSet::Create( Convert(media_type_set->details->get_compressed_audio()->encoding), - Convert(media_type_set->details->get_compressed_audio()-> - sample_format), - Range<uint32_t>( - media_type_set->details->get_lpcm()->min_channels, - media_type_set->details->get_lpcm()->max_channels), + Convert( + media_type_set->details->get_compressed_audio()->sample_format), + Range<uint32_t>(media_type_set->details->get_lpcm()->min_channels, + media_type_set->details->get_lpcm()->max_channels), Range<uint32_t>( media_type_set->details->get_lpcm()->min_frames_per_second, media_type_set->details->get_lpcm()->max_frames_per_second)); case MediaTypeScheme::VIDEO: return VideoStreamTypeSet::Create( Convert(media_type_set->details->get_video()->encoding), - Range<uint32_t>( - media_type_set->details->get_video()->min_width, - media_type_set->details->get_video()->max_width), - Range<uint32_t>( - media_type_set->details->get_video()->min_height, - media_type_set->details->get_video()->max_height)); + Range<uint32_t>(media_type_set->details->get_video()->min_width, + media_type_set->details->get_video()->max_width), + Range<uint32_t>(media_type_set->details->get_video()->min_height, + media_type_set->details->get_video()->max_height)); default: return StreamTypeSet::Create(Convert(media_type_set->scheme)); } @@ -298,10 +292,8 @@ size_t byte_count = modp_b64_decode_len(base64_size); std::unique_ptr<Bytes> bytes = Bytes::Create(byte_count); - byte_count = modp_b64_decode( - reinterpret_cast<char*>(bytes->data()), - base64.data(), - base64_size); + byte_count = modp_b64_decode(reinterpret_cast<char*>(bytes->data()), + base64.data(), base64_size); if (byte_count == MODP_B64_ERROR) { return nullptr; @@ -315,14 +307,10 @@ return nullptr; } - return Metadata::Create( - media_metadata->duration, - media_metadata->title, - media_metadata->artist, - media_metadata->album, - media_metadata->publisher, - media_metadata->genre, - media_metadata->composer); + return Metadata::Create(media_metadata->duration, media_metadata->title, + media_metadata->artist, media_metadata->album, + media_metadata->publisher, media_metadata->genre, + media_metadata->composer); } // Creates a MediaTypeScheme from a StreamType::Scheme. @@ -523,8 +511,7 @@ return media_type; } case StreamType::Scheme::kLpcm: { - LpcmMediaTypeDetailsPtr lpcm_details = - LpcmMediaTypeDetails::New(); + LpcmMediaTypeDetailsPtr lpcm_details = LpcmMediaTypeDetails::New(); lpcm_details->sample_format = Convert(stream_type->lpcm()->sample_format()); lpcm_details->channels = stream_type->lpcm()->channels(); @@ -558,8 +545,7 @@ return media_type; } case StreamType::Scheme::kVideo: { - VideoMediaTypeDetailsPtr video_details = - VideoMediaTypeDetails::New(); + VideoMediaTypeDetailsPtr video_details = VideoMediaTypeDetails::New(); video_details->encoding = Convert(stream_type->video()->encoding()); video_details->profile = Convert(stream_type->video()->profile()); video_details->pixel_format = @@ -623,8 +609,7 @@ return media_type_set; } case StreamType::Scheme::kLpcm: { - LpcmMediaTypeSetDetailsPtr lpcm_details = - LpcmMediaTypeSetDetails::New(); + LpcmMediaTypeSetDetailsPtr lpcm_details = LpcmMediaTypeSetDetails::New(); lpcm_details->sample_format = Convert(stream_type_set->lpcm()->sample_format()); lpcm_details->min_channels = stream_type_set->lpcm()->channels().min; @@ -697,7 +682,7 @@ Array<MediaTypeSetPtr> result = Array<MediaTypeSetPtr>::New(stream_type_sets->size()); for (const std::unique_ptr<StreamTypeSet>& stream_type_set : - *stream_type_sets) { + *stream_type_sets) { result.push_back(Convert(stream_type_set)); } return result; @@ -714,9 +699,7 @@ // modp_b64_encode_len() returns at least 1, so temp[0] is safe to use. size_t output_size = modp_b64_encode( - &(temp[0]), - reinterpret_cast<char*>(bytes->data()), - bytes->size()); + &(temp[0]), reinterpret_cast<char*>(bytes->data()), bytes->size()); temp.resize(output_size); // Strips off null byte.
diff --git a/services/media/framework_mojo/mojo_type_conversions.h b/services/media/framework_mojo/mojo_type_conversions.h index bb9e18e..71e0ac4 100644 --- a/services/media/framework_mojo/mojo_type_conversions.h +++ b/services/media/framework_mojo/mojo_type_conversions.h
@@ -38,8 +38,8 @@ std::unique_ptr<StreamType> Convert(const MediaTypePtr& media_type); // Creates std::vector<std::unique_ptr<StreamType>> from an array of MediaTypes. -std::unique_ptr<std::vector<std::unique_ptr<StreamType>>> - Convert(const Array<MediaTypePtr>& media_types); +std::unique_ptr<std::vector<std::unique_ptr<StreamType>>> Convert( + const Array<MediaTypePtr>& media_types); // Creates a StreamTypeSet from a MediaTypeSet. std::unique_ptr<StreamTypeSet> Convert(const MediaTypeSetPtr& media_type_set); @@ -82,7 +82,7 @@ // Creates an array of MediaTypes from std::vector<std::unique_ptr<StreamType>>. Array<MediaTypePtr> Convert( const std::unique_ptr<std::vector<std::unique_ptr<StreamType>>>& - stream_types); + stream_types); // Creates a MediaTypeSet from a StreamTypeSet. MediaTypeSetPtr Convert(const std::unique_ptr<StreamTypeSet>& stream_type_set); @@ -102,4 +102,4 @@ } // namespace media } // namespace mojo -#endif // SERVICES_MEDIA_FRAMEWORK_MOJO_MOJO_TYPE_CONVERSIONS_H_ +#endif // SERVICES_MEDIA_FRAMEWORK_MOJO_MOJO_TYPE_CONVERSIONS_H_