| OLD | NEW |
| 1 /* | 1 /* |
| 2 * libjingle | 2 * libjingle |
| 3 * Copyright 2015 Google Inc. | 3 * Copyright 2015 Google Inc. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions are met: | 6 * modification, are permitted provided that the following conditions are met: |
| 7 * | 7 * |
| 8 * 1. Redistributions of source code must retain the above copyright notice, | 8 * 1. Redistributions of source code must retain the above copyright notice, |
| 9 * this list of conditions and the following disclaimer. | 9 * this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright notice, | 10 * 2. Redistributions in binary form must reproduce the above copyright notice, |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 int64_t /* rtt */) override; | 99 int64_t /* rtt */) override; |
| 100 int32_t SetRates(uint32_t new_bit_rate, uint32_t frame_rate) override; | 100 int32_t SetRates(uint32_t new_bit_rate, uint32_t frame_rate) override; |
| 101 | 101 |
| 102 // rtc::MessageHandler implementation. | 102 // rtc::MessageHandler implementation. |
| 103 void OnMessage(rtc::Message* msg) override; | 103 void OnMessage(rtc::Message* msg) override; |
| 104 | 104 |
| 105 void OnDroppedFrame() override; | 105 void OnDroppedFrame() override; |
| 106 | 106 |
| 107 int GetTargetFramerate() override; | 107 int GetTargetFramerate() override; |
| 108 | 108 |
| 109 const char* ImplementationName() const override; |
| 110 |
| 109 private: | 111 private: |
| 110 // ResetCodecOnCodecThread() calls ReleaseOnCodecThread() and | 112 // ResetCodecOnCodecThread() calls ReleaseOnCodecThread() and |
| 111 // InitEncodeOnCodecThread() in an attempt to restore the codec to an | 113 // InitEncodeOnCodecThread() in an attempt to restore the codec to an |
| 112 // operable state. Necessary after all manner of OMX-layer errors. | 114 // operable state. Necessary after all manner of OMX-layer errors. |
| 113 void ResetCodecOnCodecThread(); | 115 void ResetCodecOnCodecThread(); |
| 114 | 116 |
| 115 // Implementation of webrtc::VideoEncoder methods above, all running on the | 117 // Implementation of webrtc::VideoEncoder methods above, all running on the |
| 116 // codec thread exclusively. | 118 // codec thread exclusively. |
| 117 // | 119 // |
| 118 // If width==0 then this is assumed to be a re-initialization and the | 120 // If width==0 then this is assumed to be a re-initialization and the |
| (...skipping 822 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 941 | 943 |
| 942 void MediaCodecVideoEncoder::OnDroppedFrame() { | 944 void MediaCodecVideoEncoder::OnDroppedFrame() { |
| 943 if (scale_) | 945 if (scale_) |
| 944 quality_scaler_.ReportDroppedFrame(); | 946 quality_scaler_.ReportDroppedFrame(); |
| 945 } | 947 } |
| 946 | 948 |
| 947 int MediaCodecVideoEncoder::GetTargetFramerate() { | 949 int MediaCodecVideoEncoder::GetTargetFramerate() { |
| 948 return scale_ ? quality_scaler_.GetTargetFramerate() : -1; | 950 return scale_ ? quality_scaler_.GetTargetFramerate() : -1; |
| 949 } | 951 } |
| 950 | 952 |
| 953 const char* MediaCodecVideoEncoder::ImplementationName() const { |
| 954 return "MediaCodec"; |
| 955 } |
| 956 |
| 951 MediaCodecVideoEncoderFactory::MediaCodecVideoEncoderFactory() { | 957 MediaCodecVideoEncoderFactory::MediaCodecVideoEncoderFactory() { |
| 952 JNIEnv* jni = AttachCurrentThreadIfNeeded(); | 958 JNIEnv* jni = AttachCurrentThreadIfNeeded(); |
| 953 ScopedLocalRefFrame local_ref_frame(jni); | 959 ScopedLocalRefFrame local_ref_frame(jni); |
| 954 jclass j_encoder_class = FindClass(jni, "org/webrtc/MediaCodecVideoEncoder"); | 960 jclass j_encoder_class = FindClass(jni, "org/webrtc/MediaCodecVideoEncoder"); |
| 955 supported_codecs_.clear(); | 961 supported_codecs_.clear(); |
| 956 | 962 |
| 957 bool is_vp8_hw_supported = jni->CallStaticBooleanMethod( | 963 bool is_vp8_hw_supported = jni->CallStaticBooleanMethod( |
| 958 j_encoder_class, | 964 j_encoder_class, |
| 959 GetStaticMethodID(jni, j_encoder_class, "isVp8HwSupported", "()Z")); | 965 GetStaticMethodID(jni, j_encoder_class, "isVp8HwSupported", "()Z")); |
| 960 CHECK_EXCEPTION(jni); | 966 CHECK_EXCEPTION(jni); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 999 } | 1005 } |
| 1000 | 1006 |
| 1001 void MediaCodecVideoEncoderFactory::DestroyVideoEncoder( | 1007 void MediaCodecVideoEncoderFactory::DestroyVideoEncoder( |
| 1002 webrtc::VideoEncoder* encoder) { | 1008 webrtc::VideoEncoder* encoder) { |
| 1003 ALOGD << "Destroy video encoder."; | 1009 ALOGD << "Destroy video encoder."; |
| 1004 delete encoder; | 1010 delete encoder; |
| 1005 } | 1011 } |
| 1006 | 1012 |
| 1007 } // namespace webrtc_jni | 1013 } // namespace webrtc_jni |
| 1008 | 1014 |
| OLD | NEW |