Loading media/libstagefright/MediaCodec.cpp +52 −0 Original line number Original line Diff line number Diff line Loading @@ -664,6 +664,7 @@ enum { kWhatOutputBuffersChanged = 'outC', kWhatOutputBuffersChanged = 'outC', kWhatFirstTunnelFrameReady = 'ftfR', kWhatFirstTunnelFrameReady = 'ftfR', kWhatPollForRenderedBuffers = 'plrb', kWhatPollForRenderedBuffers = 'plrb', kWhatMetricsUpdated = 'mtru', }; }; class CryptoAsyncCallback : public CryptoAsync::CryptoAsyncCallback { class CryptoAsyncCallback : public CryptoAsync::CryptoAsyncCallback { Loading Loading @@ -761,6 +762,7 @@ public: virtual void onOutputFramesRendered(const std::list<RenderedFrameInfo> &done) override; virtual void onOutputFramesRendered(const std::list<RenderedFrameInfo> &done) override; virtual void onOutputBuffersChanged() override; virtual void onOutputBuffersChanged() override; virtual void onFirstTunnelFrameReady() override; virtual void onFirstTunnelFrameReady() override; virtual void onMetricsUpdated(const sp<AMessage> &updatedMetrics) override; private: private: const sp<AMessage> mNotify; const sp<AMessage> mNotify; }; }; Loading Loading @@ -887,6 +889,13 @@ void CodecCallback::onFirstTunnelFrameReady() { notify->post(); notify->post(); } } void CodecCallback::onMetricsUpdated(const sp<AMessage> &updatedMetrics) { sp<AMessage> notify(mNotify->dup()); notify->setInt32("what", kWhatMetricsUpdated); notify->setMessage("updated-metrics", updatedMetrics); notify->post(); } static MediaResourceSubType toMediaResourceSubType(MediaCodec::Domain domain) { static MediaResourceSubType toMediaResourceSubType(MediaCodec::Domain domain) { switch (domain) { switch (domain) { case MediaCodec::DOMAIN_VIDEO: return MediaResourceSubType::kVideoCodec; case MediaCodec::DOMAIN_VIDEO: return MediaResourceSubType::kVideoCodec; Loading Loading @@ -4257,6 +4266,49 @@ void MediaCodec::onMessageReceived(const sp<AMessage> &msg) { break; break; } } case kWhatMetricsUpdated: { sp<AMessage> updatedMetrics; CHECK(msg->findMessage("updated-metrics", &updatedMetrics)); size_t numEntries = updatedMetrics->countEntries(); AMessage::Type type; for (size_t i = 0; i < numEntries; ++i) { const char *name = updatedMetrics->getEntryNameAt(i, &type); AMessage::ItemData itemData = updatedMetrics->getEntryAt(i); switch (type) { case AMessage::kTypeInt32: { int32_t metricValue; itemData.find(&metricValue); mediametrics_setInt32(mMetricsHandle, name, metricValue); break; } case AMessage::kTypeInt64: { int64_t metricValue; itemData.find(&metricValue); mediametrics_setInt64(mMetricsHandle, name, metricValue); break; } case AMessage::kTypeDouble: { double metricValue; itemData.find(&metricValue); mediametrics_setDouble(mMetricsHandle, name, metricValue); break; } case AMessage::kTypeString: { AString metricValue; itemData.find(&metricValue); mediametrics_setCString(mMetricsHandle, name, metricValue.c_str()); break; } // ToDo: add support for other types default: ALOGW("Updated metrics type not supported."); } } break; } case kWhatEOS: case kWhatEOS: { { // We already notify the client of this by using the // We already notify the client of this by using the Loading media/libstagefright/include/media/stagefright/CodecBase.h +6 −0 Original line number Original line Diff line number Diff line Loading @@ -182,6 +182,12 @@ struct CodecBase : public AHandler, /* static */ ColorUtils { * Notify MediaCodec that the first tunnel frame is ready. * Notify MediaCodec that the first tunnel frame is ready. */ */ virtual void onFirstTunnelFrameReady() = 0; virtual void onFirstTunnelFrameReady() = 0; /** * Notify MediaCodec that there are metrics to be updated. * * @param updatedMetrics metrics need to be updated. */ virtual void onMetricsUpdated(const sp<AMessage> &updatedMetrics) = 0; }; }; /** /** Loading Loading
media/libstagefright/MediaCodec.cpp +52 −0 Original line number Original line Diff line number Diff line Loading @@ -664,6 +664,7 @@ enum { kWhatOutputBuffersChanged = 'outC', kWhatOutputBuffersChanged = 'outC', kWhatFirstTunnelFrameReady = 'ftfR', kWhatFirstTunnelFrameReady = 'ftfR', kWhatPollForRenderedBuffers = 'plrb', kWhatPollForRenderedBuffers = 'plrb', kWhatMetricsUpdated = 'mtru', }; }; class CryptoAsyncCallback : public CryptoAsync::CryptoAsyncCallback { class CryptoAsyncCallback : public CryptoAsync::CryptoAsyncCallback { Loading Loading @@ -761,6 +762,7 @@ public: virtual void onOutputFramesRendered(const std::list<RenderedFrameInfo> &done) override; virtual void onOutputFramesRendered(const std::list<RenderedFrameInfo> &done) override; virtual void onOutputBuffersChanged() override; virtual void onOutputBuffersChanged() override; virtual void onFirstTunnelFrameReady() override; virtual void onFirstTunnelFrameReady() override; virtual void onMetricsUpdated(const sp<AMessage> &updatedMetrics) override; private: private: const sp<AMessage> mNotify; const sp<AMessage> mNotify; }; }; Loading Loading @@ -887,6 +889,13 @@ void CodecCallback::onFirstTunnelFrameReady() { notify->post(); notify->post(); } } void CodecCallback::onMetricsUpdated(const sp<AMessage> &updatedMetrics) { sp<AMessage> notify(mNotify->dup()); notify->setInt32("what", kWhatMetricsUpdated); notify->setMessage("updated-metrics", updatedMetrics); notify->post(); } static MediaResourceSubType toMediaResourceSubType(MediaCodec::Domain domain) { static MediaResourceSubType toMediaResourceSubType(MediaCodec::Domain domain) { switch (domain) { switch (domain) { case MediaCodec::DOMAIN_VIDEO: return MediaResourceSubType::kVideoCodec; case MediaCodec::DOMAIN_VIDEO: return MediaResourceSubType::kVideoCodec; Loading Loading @@ -4257,6 +4266,49 @@ void MediaCodec::onMessageReceived(const sp<AMessage> &msg) { break; break; } } case kWhatMetricsUpdated: { sp<AMessage> updatedMetrics; CHECK(msg->findMessage("updated-metrics", &updatedMetrics)); size_t numEntries = updatedMetrics->countEntries(); AMessage::Type type; for (size_t i = 0; i < numEntries; ++i) { const char *name = updatedMetrics->getEntryNameAt(i, &type); AMessage::ItemData itemData = updatedMetrics->getEntryAt(i); switch (type) { case AMessage::kTypeInt32: { int32_t metricValue; itemData.find(&metricValue); mediametrics_setInt32(mMetricsHandle, name, metricValue); break; } case AMessage::kTypeInt64: { int64_t metricValue; itemData.find(&metricValue); mediametrics_setInt64(mMetricsHandle, name, metricValue); break; } case AMessage::kTypeDouble: { double metricValue; itemData.find(&metricValue); mediametrics_setDouble(mMetricsHandle, name, metricValue); break; } case AMessage::kTypeString: { AString metricValue; itemData.find(&metricValue); mediametrics_setCString(mMetricsHandle, name, metricValue.c_str()); break; } // ToDo: add support for other types default: ALOGW("Updated metrics type not supported."); } } break; } case kWhatEOS: case kWhatEOS: { { // We already notify the client of this by using the // We already notify the client of this by using the Loading
media/libstagefright/include/media/stagefright/CodecBase.h +6 −0 Original line number Original line Diff line number Diff line Loading @@ -182,6 +182,12 @@ struct CodecBase : public AHandler, /* static */ ColorUtils { * Notify MediaCodec that the first tunnel frame is ready. * Notify MediaCodec that the first tunnel frame is ready. */ */ virtual void onFirstTunnelFrameReady() = 0; virtual void onFirstTunnelFrameReady() = 0; /** * Notify MediaCodec that there are metrics to be updated. * * @param updatedMetrics metrics need to be updated. */ virtual void onMetricsUpdated(const sp<AMessage> &updatedMetrics) = 0; }; }; /** /** Loading