Code Monkey home page Code Monkey logo

Comments (3)

nickhuangcyh avatar nickhuangcyh commented on July 17, 2024 2

Hi @rach21nag,

Here is the file where i modify the source code of webrtc for your reference

  1. Go to webrtc.github.io (Android development is only supported on Linux.)
  2. Pull source code
  3. modify these files below (Enable hardware video ecoder for all chips and software openh264 media codec)
diff --git a/sdk/android/api/org/webrtc/HardwareVideoEncoderFactory.java b/sdk/android/api/org/webrtc/HardwareVideoEncoderFactory.java
index 9cd4aa2d37..9903300a36 100644
--- a/sdk/android/api/org/webrtc/HardwareVideoEncoderFactory.java
+++ b/sdk/android/api/org/webrtc/HardwareVideoEncoderFactory.java
@@ -232,11 +232,15 @@ public class HardwareVideoEncoderFactory implements VideoEncoderFactory {
       return false;
     }
     String name = info.getName();
+
+    return true;
+    /*
     // QCOM H264 encoder is supported in KITKAT or later.
     return (name.startsWith(QCOM_PREFIX) && Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT)
         // Exynos H264 encoder is supported in LOLLIPOP or later.
         || (name.startsWith(EXYNOS_PREFIX)
                && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP);
+    */
   }
 
   private boolean isMediaCodecAllowed(MediaCodecInfo info) {
diff --git a/sdk/android/src/java/org/webrtc/MediaCodecUtils.java b/sdk/android/src/java/org/webrtc/MediaCodecUtils.java
index 5d83014dc3..bb7bed4e29 100644
--- a/sdk/android/src/java/org/webrtc/MediaCodecUtils.java
+++ b/sdk/android/src/java/org/webrtc/MediaCodecUtils.java
@@ -30,7 +30,7 @@ class MediaCodecUtils {
   static final String NVIDIA_PREFIX = "OMX.Nvidia.";
   static final String QCOM_PREFIX = "OMX.qcom.";
   static final String[] SOFTWARE_IMPLEMENTATION_PREFIXES = {
-      "OMX.google.", "OMX.SEC.", "c2.android"};
+      "OMX.SEC.", "c2.android"};
 
   // NV12 color format supported by QCOM codec, but not declared in MediaCodec -
   // see /hardware/qcom/media/mm-core/inc/OMX_QCOMExtns.h
  1. Build .aar for Android
    tools_webrtc/android/build_aar.py --arch "armeabi-v7a" "arm64-v8a" --extra-gn-args='rtc_use_h264=true ffmpeg_branding = "Chrome" proprietary_codecs=true'
  2. πŸŽ‰

from amazon-kinesis-video-streams-webrtc-sdk-android.

nickhuangcyh avatar nickhuangcyh commented on July 17, 2024 1

Hi @rach21nag,

I have the same problem as you and I finally solved this problem

Master: Linux embeded system with mediatek chip
Viewer: Multiple Android Phones

The problem is that our embeded system only supports H264 video codec format but not VP8/VP9 video codec format
Most Android devices only support VP8/VP9 video codec on WebRTC
Currently WebRTC hardware encoding only supports devices that using QCOM and EXYNOS chips
You can find out in the link below
Why WebRTC only support H264 in Chrome but not in native application with some devices

You can check the SDP packet to find the supported video codec
[For example]
(Embedded System -> Android Phone SDP)
m=video 9 UDP/TLS/RTP/SAVPF 96 97 98 99 100 101 127
a=rtpmap:0 H264
...
(Android Phone -> Embedded System SDP)
m=video 9 UDP/TLS/RTP/SAVPF 96 97 98 99 100 101 127
a=rtpmap:96 VP8/90000

The supported video codecs on both sides do not match

And I can't change the embedded system chip to support VP8/VP9 codec
So I can only solve this problem from Android's WebRTC SDK
I modified and recompiled the source code of WebRTC so that it can also support H264 on different chips (AMD, Mediatek...)

  1. Enable the hardware encoder for all chips
  2. Enable the software encoder for all chips

And now it works perfectly on all my android devices

BTW
I'm not a native english speaker, hope you can understand what i mean

BR,
Nick

from amazon-kinesis-video-streams-webrtc-sdk-android.

rach21nag avatar rach21nag commented on July 17, 2024

Thank you for your reply! I will try this out :)

from amazon-kinesis-video-streams-webrtc-sdk-android.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.