Loading media/codec2/core/include/C2Config.h +31 −2 Original line number Diff line number Diff line Loading @@ -269,7 +269,7 @@ enum C2ParamIndexKind : C2Param::type_index_t { kParamIndexSuspendAt, // input-surface, struct kParamIndexResumeAt, // input-surface, struct kParamIndexStopAt, // input-surface, struct kParamIndexTimeOffset, // input-surface, struct kParamIndexTimeOffset, // input-surface, int64_t kParamIndexMinFrameRate, // input-surface, float kParamIndexTimestampGapAdjustment, // input-surface, struct Loading Loading @@ -299,6 +299,10 @@ enum C2ParamIndexKind : C2Param::type_index_t { // allow tunnel peek behavior to be unspecified for app compatibility kParamIndexTunnelPeekMode, // tunnel mode, enum // input surface kParamIndexCaptureFrameRate, // input-surface, float kParamIndexStopTimeOffset, // input-surface, int64_t }; } Loading Loading @@ -2650,6 +2654,14 @@ constexpr char C2_PARAMKEY_INPUT_SURFACE_TIME_OFFSET[] = "input-surface.time-off typedef C2PortParam<C2Tuning, C2FloatValue, kParamIndexMinFrameRate> C2PortMinFrameRateTuning; constexpr char C2_PARAMKEY_INPUT_SURFACE_MIN_FRAME_RATE[] = "input-surface.min-frame-rate"; /** * Maximum fps for input surface. * * Drop frame to meet this. */ typedef C2PortParam<C2Tuning, C2FloatValue, kParamIndexMaxFrameRate> C2PortMaxFrameRateTuning; constexpr char C2_PARAMKEY_INPUT_SURFACE_MAX_FRAME_RATE[] = "input-surface.max-frame-rate"; /** * Timestamp adjustment (override) for input surface buffers. These control the input timestamp * fed to the codec, but do not impact the output timestamp. Loading Loading @@ -2680,9 +2692,26 @@ C2ENUM(C2TimestampGapAdjustmentStruct::mode_t, uint32_t, inline C2TimestampGapAdjustmentStruct::C2TimestampGapAdjustmentStruct() : mode(C2TimestampGapAdjustmentStruct::NONE), value(0) { } typedef C2PortParam<C2Tuning, C2TimestampGapAdjustmentStruct> C2PortTimestampGapTuning; typedef C2PortParam<C2Tuning, C2TimestampGapAdjustmentStruct, kParamIndexTimestampGapAdjustment> C2PortTimestampGapTuning; constexpr char C2_PARAMKEY_INPUT_SURFACE_TIMESTAMP_ADJUSTMENT[] = "input-surface.timestamp-adjustment"; /** * Capture frame rate for input surface. During timelapse or slowmo encoding, * this represents the frame rate of input surface. */ typedef C2PortParam<C2Tuning, C2FloatValue, kParamIndexCaptureFrameRate> C2PortCaptureFrameRateTuning; constexpr char C2_PARAMKEY_INPUT_SURFACE_CAPTURE_FRAME_RATE[] = "input-surface.capture-frame-rate"; /** * Stop time offset for input surface. Stop time offset is the elapsed time * offset to the last frame time from the stop time. This could be returned from * IInputSurface when it is queried. */ typedef C2PortParam<C2Tuning, C2Int64Value, kParamIndexStopTimeOffset> C2PortStopTimeOffset; constexpr char C2_PARAMKEY_INPUT_SURFACE_STOP_TIME_OFFSET[] = "input-surface.stop-time-offset"; /* ===================================== TUNNELED CODEC ==================================== */ /** Loading media/codec2/hal/aidl/Android.bp +3 −0 Original line number Diff line number Diff line Loading @@ -78,6 +78,8 @@ cc_library { "Configurable.cpp", "InputBufferManager.cpp", "ParamTypes.cpp", "inputsurface/InputSurface.cpp", "inputsurface/InputSurfaceConnection.cpp", ], header_libs: [ Loading @@ -98,6 +100,7 @@ cc_library { "libhidlbase", "liblog", "libnativewindow", "libmediandk", "libstagefright_aidl_bufferpool2", "libstagefright_bufferpool@2.0.1", "libui", Loading media/codec2/hal/aidl/include/codec2/aidl/inputsurface/InputSurface.h 0 → 100644 +61 −0 Original line number Diff line number Diff line /* * Copyright 2024 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #pragma once #include <aidl/android/hardware/media/c2/BnInputSurface.h> #include <codec2/aidl/Configurable.h> #include <util/C2InterfaceHelper.h> #include <C2.h> #include <memory> namespace aidl::android::hardware::media::c2::utils { struct InputSurface : public BnInputSurface { InputSurface(); c2_status_t status() const; // Methods from IInputSurface follow. ::ndk::ScopedAStatus getSurface( ::aidl::android::view::Surface* surface) override; ::ndk::ScopedAStatus getConfigurable( std::shared_ptr<IConfigurable>* configurable) override; ::ndk::ScopedAStatus connect( const std::shared_ptr<IInputSink>& sink, std::shared_ptr<IInputSurfaceConnection>* connection) override; protected: class Interface; class ConfigurableIntf; c2_status_t mInit; std::shared_ptr<Interface> mIntf; std::shared_ptr<CachedConfigurable> mConfigurable; virtual ~InputSurface() override; ::ndk::ScopedAIBinder_DeathRecipient mDeathRecipient; static void OnBinderDied(void *cookie); static void OnBinderUnlinked(void *cookie); struct DeathContext; DeathContext *mDeathContext; }; } // namespace aidl::android::hardware::media::c2::utils media/codec2/hal/aidl/include/codec2/aidl/inputsurface/InputSurfaceConnection.h 0 → 100644 +56 −0 Original line number Diff line number Diff line /* * Copyright 2024 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #pragma once #include <aidl/android/hardware/media/c2/BnInputSurfaceConnection.h> #include <media/NdkImage.h> #include <C2.h> #include <memory> namespace aidl::android::hardware::media::c2::utils { struct InputSurfaceConnection : public BnInputSurfaceConnection { InputSurfaceConnection(); c2_status_t status() const; // Methods from IInputSurfaceConnection follow. ::ndk::ScopedAStatus disconnect() override; ::ndk::ScopedAStatus signalEndOfStream() override; // implementation specific interface. // Submit a buffer to the connected component. c2_status_t submitBuffer( int32_t bufferId, const AImage *buffer = nullptr, int64_t timestamp = 0, int fenceFd = -1); // Submit eos to the connected component. c2_status_t submitEos(int32_t bufferId); // notify dataspace being changed to the component. void dispatchDataSpaceChanged( int32_t dataSpace, int32_t aspects, int32_t pixelFormat); protected: virtual ~InputSurfaceConnection() override; }; } // namespace aidl::android::hardware::media::c2::utils media/codec2/hal/aidl/inputsurface/InputSurface.cpp 0 → 100644 +81 −0 Original line number Diff line number Diff line /* * Copyright 2024 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ //#define LOG_NDEBUG 0 #define LOG_TAG "Codec2-InputSurface" #include <android-base/logging.h> #include <codec2/aidl/inputsurface/InputSurface.h> namespace aidl::android::hardware::media::c2::utils { // Derived class of C2InterfaceHelper class InputSurface::Interface : public C2InterfaceHelper { public: explicit Interface( const std::shared_ptr<C2ReflectorHelper> &helper) : C2InterfaceHelper(helper) { setDerivedInstance(this); } private: }; class InputSurface::ConfigurableIntf : public ConfigurableC2Intf { public: }; struct InputSurface::DeathContext { // TODO; }; void InputSurface::OnBinderDied(void *cookie) { (void) cookie; } void InputSurface::OnBinderUnlinked(void *cookie) { (void) cookie; } InputSurface::InputSurface() : mDeathContext(nullptr) { mInit = C2_OK; } InputSurface::~InputSurface() { } ::ndk::ScopedAStatus InputSurface::getSurface(::aidl::android::view::Surface* surface) { (void) surface; return ::ndk::ScopedAStatus::ok(); } ::ndk::ScopedAStatus InputSurface::getConfigurable( std::shared_ptr<IConfigurable>* configurable) { *configurable = mConfigurable; return ::ndk::ScopedAStatus::ok(); } ::ndk::ScopedAStatus InputSurface::connect( const std::shared_ptr<IInputSink>& sink, std::shared_ptr<IInputSurfaceConnection>* connection) { (void) sink; (void) connection; return ::ndk::ScopedAStatus::ok(); } } // namespace aidl::android::hardware::media::c2::utils Loading
media/codec2/core/include/C2Config.h +31 −2 Original line number Diff line number Diff line Loading @@ -269,7 +269,7 @@ enum C2ParamIndexKind : C2Param::type_index_t { kParamIndexSuspendAt, // input-surface, struct kParamIndexResumeAt, // input-surface, struct kParamIndexStopAt, // input-surface, struct kParamIndexTimeOffset, // input-surface, struct kParamIndexTimeOffset, // input-surface, int64_t kParamIndexMinFrameRate, // input-surface, float kParamIndexTimestampGapAdjustment, // input-surface, struct Loading Loading @@ -299,6 +299,10 @@ enum C2ParamIndexKind : C2Param::type_index_t { // allow tunnel peek behavior to be unspecified for app compatibility kParamIndexTunnelPeekMode, // tunnel mode, enum // input surface kParamIndexCaptureFrameRate, // input-surface, float kParamIndexStopTimeOffset, // input-surface, int64_t }; } Loading Loading @@ -2650,6 +2654,14 @@ constexpr char C2_PARAMKEY_INPUT_SURFACE_TIME_OFFSET[] = "input-surface.time-off typedef C2PortParam<C2Tuning, C2FloatValue, kParamIndexMinFrameRate> C2PortMinFrameRateTuning; constexpr char C2_PARAMKEY_INPUT_SURFACE_MIN_FRAME_RATE[] = "input-surface.min-frame-rate"; /** * Maximum fps for input surface. * * Drop frame to meet this. */ typedef C2PortParam<C2Tuning, C2FloatValue, kParamIndexMaxFrameRate> C2PortMaxFrameRateTuning; constexpr char C2_PARAMKEY_INPUT_SURFACE_MAX_FRAME_RATE[] = "input-surface.max-frame-rate"; /** * Timestamp adjustment (override) for input surface buffers. These control the input timestamp * fed to the codec, but do not impact the output timestamp. Loading Loading @@ -2680,9 +2692,26 @@ C2ENUM(C2TimestampGapAdjustmentStruct::mode_t, uint32_t, inline C2TimestampGapAdjustmentStruct::C2TimestampGapAdjustmentStruct() : mode(C2TimestampGapAdjustmentStruct::NONE), value(0) { } typedef C2PortParam<C2Tuning, C2TimestampGapAdjustmentStruct> C2PortTimestampGapTuning; typedef C2PortParam<C2Tuning, C2TimestampGapAdjustmentStruct, kParamIndexTimestampGapAdjustment> C2PortTimestampGapTuning; constexpr char C2_PARAMKEY_INPUT_SURFACE_TIMESTAMP_ADJUSTMENT[] = "input-surface.timestamp-adjustment"; /** * Capture frame rate for input surface. During timelapse or slowmo encoding, * this represents the frame rate of input surface. */ typedef C2PortParam<C2Tuning, C2FloatValue, kParamIndexCaptureFrameRate> C2PortCaptureFrameRateTuning; constexpr char C2_PARAMKEY_INPUT_SURFACE_CAPTURE_FRAME_RATE[] = "input-surface.capture-frame-rate"; /** * Stop time offset for input surface. Stop time offset is the elapsed time * offset to the last frame time from the stop time. This could be returned from * IInputSurface when it is queried. */ typedef C2PortParam<C2Tuning, C2Int64Value, kParamIndexStopTimeOffset> C2PortStopTimeOffset; constexpr char C2_PARAMKEY_INPUT_SURFACE_STOP_TIME_OFFSET[] = "input-surface.stop-time-offset"; /* ===================================== TUNNELED CODEC ==================================== */ /** Loading
media/codec2/hal/aidl/Android.bp +3 −0 Original line number Diff line number Diff line Loading @@ -78,6 +78,8 @@ cc_library { "Configurable.cpp", "InputBufferManager.cpp", "ParamTypes.cpp", "inputsurface/InputSurface.cpp", "inputsurface/InputSurfaceConnection.cpp", ], header_libs: [ Loading @@ -98,6 +100,7 @@ cc_library { "libhidlbase", "liblog", "libnativewindow", "libmediandk", "libstagefright_aidl_bufferpool2", "libstagefright_bufferpool@2.0.1", "libui", Loading
media/codec2/hal/aidl/include/codec2/aidl/inputsurface/InputSurface.h 0 → 100644 +61 −0 Original line number Diff line number Diff line /* * Copyright 2024 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #pragma once #include <aidl/android/hardware/media/c2/BnInputSurface.h> #include <codec2/aidl/Configurable.h> #include <util/C2InterfaceHelper.h> #include <C2.h> #include <memory> namespace aidl::android::hardware::media::c2::utils { struct InputSurface : public BnInputSurface { InputSurface(); c2_status_t status() const; // Methods from IInputSurface follow. ::ndk::ScopedAStatus getSurface( ::aidl::android::view::Surface* surface) override; ::ndk::ScopedAStatus getConfigurable( std::shared_ptr<IConfigurable>* configurable) override; ::ndk::ScopedAStatus connect( const std::shared_ptr<IInputSink>& sink, std::shared_ptr<IInputSurfaceConnection>* connection) override; protected: class Interface; class ConfigurableIntf; c2_status_t mInit; std::shared_ptr<Interface> mIntf; std::shared_ptr<CachedConfigurable> mConfigurable; virtual ~InputSurface() override; ::ndk::ScopedAIBinder_DeathRecipient mDeathRecipient; static void OnBinderDied(void *cookie); static void OnBinderUnlinked(void *cookie); struct DeathContext; DeathContext *mDeathContext; }; } // namespace aidl::android::hardware::media::c2::utils
media/codec2/hal/aidl/include/codec2/aidl/inputsurface/InputSurfaceConnection.h 0 → 100644 +56 −0 Original line number Diff line number Diff line /* * Copyright 2024 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #pragma once #include <aidl/android/hardware/media/c2/BnInputSurfaceConnection.h> #include <media/NdkImage.h> #include <C2.h> #include <memory> namespace aidl::android::hardware::media::c2::utils { struct InputSurfaceConnection : public BnInputSurfaceConnection { InputSurfaceConnection(); c2_status_t status() const; // Methods from IInputSurfaceConnection follow. ::ndk::ScopedAStatus disconnect() override; ::ndk::ScopedAStatus signalEndOfStream() override; // implementation specific interface. // Submit a buffer to the connected component. c2_status_t submitBuffer( int32_t bufferId, const AImage *buffer = nullptr, int64_t timestamp = 0, int fenceFd = -1); // Submit eos to the connected component. c2_status_t submitEos(int32_t bufferId); // notify dataspace being changed to the component. void dispatchDataSpaceChanged( int32_t dataSpace, int32_t aspects, int32_t pixelFormat); protected: virtual ~InputSurfaceConnection() override; }; } // namespace aidl::android::hardware::media::c2::utils
media/codec2/hal/aidl/inputsurface/InputSurface.cpp 0 → 100644 +81 −0 Original line number Diff line number Diff line /* * Copyright 2024 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ //#define LOG_NDEBUG 0 #define LOG_TAG "Codec2-InputSurface" #include <android-base/logging.h> #include <codec2/aidl/inputsurface/InputSurface.h> namespace aidl::android::hardware::media::c2::utils { // Derived class of C2InterfaceHelper class InputSurface::Interface : public C2InterfaceHelper { public: explicit Interface( const std::shared_ptr<C2ReflectorHelper> &helper) : C2InterfaceHelper(helper) { setDerivedInstance(this); } private: }; class InputSurface::ConfigurableIntf : public ConfigurableC2Intf { public: }; struct InputSurface::DeathContext { // TODO; }; void InputSurface::OnBinderDied(void *cookie) { (void) cookie; } void InputSurface::OnBinderUnlinked(void *cookie) { (void) cookie; } InputSurface::InputSurface() : mDeathContext(nullptr) { mInit = C2_OK; } InputSurface::~InputSurface() { } ::ndk::ScopedAStatus InputSurface::getSurface(::aidl::android::view::Surface* surface) { (void) surface; return ::ndk::ScopedAStatus::ok(); } ::ndk::ScopedAStatus InputSurface::getConfigurable( std::shared_ptr<IConfigurable>* configurable) { *configurable = mConfigurable; return ::ndk::ScopedAStatus::ok(); } ::ndk::ScopedAStatus InputSurface::connect( const std::shared_ptr<IInputSink>& sink, std::shared_ptr<IInputSurfaceConnection>* connection) { (void) sink; (void) connection; return ::ndk::ScopedAStatus::ok(); } } // namespace aidl::android::hardware::media::c2::utils