MEnigma / flutter_rtmp

flutter rtmp
MIT License
42 stars 15 forks source link

安卓手机集成plugin真机调试出现问题 #14

Open zlongCoding opened 4 years ago

zlongCoding commented 4 years ago

作者大大帮忙看看呗,手机是小米,安卓系统是10

D/RtmpConnection( 3063): connect(): socket connection established, doing handhake...
D/Handshake( 3063): writeC0
D/Handshake( 3063): writeC1
D/Handshake( 3063): writeC1(): Calculating digest offset
D/Handshake( 3063): writeC1(): (real value of) digestOffset: 146
D/Handshake( 3063): writeC1(): recalculated digestOffset: 922
D/Handshake( 3063): writeC1(): digestOffsetBytes: 00000092
D/Handshake( 3063): partBeforeDigest(): size: 922
D/Handshake( 3063): writeC1(): Writing timestamp and Flash Player version
D/Handshake( 3063): partAfterDigest(): size: 582
D/Handshake( 3063): copying digest offset bytes in partBeforeDigest
D/Handshake( 3063): writeC1(): Calculating digest
D/Handshake( 3063): writeC1(): writing C1 packet
D/Handshake( 3063): readS0
I/ExtendedACodec( 3063): setupVideoEncoder()
W/OMXUtils( 3063): do not know color format 0x7fa30c06 = 2141391878
W/OMXUtils( 3063): do not know color format 0x7fa30c04 = 2141391876
W/OMXUtils( 3063): do not know color format 0x7fa30c08 = 2141391880
W/OMXUtils( 3063): do not know color format 0x7fa30c07 = 2141391879
W/OMXUtils( 3063): do not know color format 0x7f000789 = 2130708361
E/ACodec  ( 3063): [OMX.qcom.video.encoder.avc] failed to set input port definition parameters.
E/ExtendedACodec( 3063): [OMX.qcom.video.encoder.avc] configureCodec returning error -1010
E/ACodec  ( 3063): signalError(omxError 0x80001001, internalError -1010)
E/ACodec  ( 3063): [OMX.qcom.video.encoder.avc] configureCodec returning error -1010
E/ACodec  ( 3063): signalError(omxError 0x80001001, internalError -1010)
E/MediaCodec( 3063): Codec reported err 0xfffffc0e, actionCode 0, while in state 3
E/MediaCodec( 3063): Codec reported err 0xfffffc0e, actionCode 0, while in state 0
E/MediaCodec( 3063): configure failed with err 0xfffffc0e, resetting...
I/OMXClient( 3063): IOmx service obtained
D/Handshake( 3063): readS1
D/Handshake( 3063): readS1(): S1 total bytes read OK
D/Handshake( 3063): writeC2
D/Handshake( 3063): readS2
D/Handshake( 3063): readS2(): S2 total bytes read OK
D/RtmpConnection( 3063): connect(): handshake done
D/RtmpConnection( 3063): rtmpConnect(): Building 'connect' invoke packet
D/RtmpConnection( 3063): starting main rx handler loop
E/MethodChannel#holo#cameraSettingConfig( 3063): Failed to handle method call
E/MethodChannel#holo#cameraSettingConfig( 3063): android.media.MediaCodec$CodecException: Error 0xfffffc0e
E/MethodChannel#holo#cameraSettingConfig( 3063):    at android.media.MediaCodec.native_configure(Native Method)
E/MethodChannel#holo#cameraSettingConfig( 3063):    at android.media.MediaCodec.configure(MediaCodec.java:2023)
E/MethodChannel#holo#cameraSettingConfig( 3063):    at android.media.MediaCodec.configure(MediaCodec.java:1951)
E/MethodChannel#holo#cameraSettingConfig( 3063):    at net.ossrs.yasea.SrsEncoder.start(SrsEncoder.java:163)
E/MethodChannel#holo#cameraSettingConfig( 3063):    at net.ossrs.yasea.SrsPublisher.startEncode(SrsPublisher.java:149)
E/MethodChannel#holo#cameraSettingConfig( 3063):    at net.ossrs.yasea.SrsPublisher.startPublish(SrsPublisher.java:177)
E/MethodChannel#holo#cameraSettingConfig( 3063):    at holo.mark.flutter_rtmp.RtmpManagerV2.startLive(rtmp.kt:146)
E/MethodChannel#holo#cameraSettingConfig( 3063):    at holo.mark.flutter_rtmp.RtmpManagerV2.onMethodCall(rtmp.kt:77)
E/MethodChannel#holo#cameraSettingConfig( 3063):    at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:226)
E/MethodChannel#holo#cameraSettingConfig( 3063):    at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:85)
E/MethodChannel#holo#cameraSettingConfig( 3063):    at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:631)
E/MethodChannel#holo#cameraSettingConfig( 3063):    at android.os.MessageQueue.nativePollOnce(Native Method)
E/MethodChannel#holo#cameraSettingConfig( 3063):    at android.os.MessageQueue.next(MessageQueue.java:336)
E/MethodChannel#holo#cameraSettingConfig( 3063):    at android.os.Looper.loop(Looper.java:181)
E/MethodChannel#holo#cameraSettingConfig( 3063):    at android.app.ActivityThread.main(ActivityThread.java:7520)
E/MethodChannel#holo#cameraSettingConfig( 3063):    at java.lang.reflect.Method.invoke(Native Method)
E/MethodChannel#holo#cameraSettingConfig( 3063):    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:539)
E/MethodChannel#holo#cameraSettingConfig( 3063):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:950)
D/RtmpConnection( 3063): wrote packet: RTMP Command (command: connect, transaction ID: 1), size: 256
D/RtmpConnection( 3063): handleRxPacketLoop(): Setting acknowledgement window size: 5000000
E/flutter ( 3063): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: PlatformException(error, Error 0xfffffc0e, null)
E/flutter ( 3063): #0      StandardMethodCodec.decodeEnvelope 
package:flutter/…/services/message_codecs.dart:569
E/flutter ( 3063): #1      MethodChannel._invokeMethod 
package:flutter/…/services/platform_channel.dart:156
E/flutter ( 3063): <asynchronous suspension>
E/flutter ( 3063): #2      MethodChannel.invokeMethod 
package:flutter/…/services/platform_channel.dart:329
E/flutter ( 3063): #3      RtmpManager.startLive 
package:flutter_rtmp/src/rtmp_manager.dart:46
E/flutter ( 3063): #4      _HomePageState.startVideoStream 
package:flutter_rtmp_example/home.dart:65
E/flutter ( 3063): #5      _HomePageState.getHttp 
package:flutter_rtmp_example/home.dart:45
E/flutter ( 3063): <asynchronous suspension>
E/flutter ( 3063): #6      _HomePageState.staticIconPerson.<anonymous closure> 
package:flutter_rtmp_example/home.dart:224
E/flutter ( 3063): #7      GestureRecognizer.invokeCallback 
E/flutter ( 3063): #8      TapGestureRecognizer.handleTapUp 
package:flutter/…/gestures/tap.dart:504
E/flutter ( 3063): #9      BaseTapGestureRecognizer._checkUp 
package:flutter/…/gestures/tap.dart:282
E/flutter ( 3063): #10     BaseTapGestureRecognizer.handlePrimaryPointer 
package:flutter/…/gestures/tap.dart:217
E/flutter ( 3063): #11     PrimaryPointerGestureRecognizer.handleEvent 
package:flutter/…/gestures/recognizer.dart:475
E/flutter ( 3063): #12     PointerRouter._dispatch 
package:flutter/…/gestures/pointer_router.dart:76
E/flutter ( 3063): #13     PointerRouter._dispatchEventToRoutes.<anonymous closure> 
package:flutter/…/gestures/pointer_router.dart:122
E/flutter ( 3063): #14     _LinkedHashMapMixin.forEach  (dart:collection-patch/compact_hash.dart:379:8)
E/flutter ( 3063): #15     PointerRouter._dispatchEventToRoutes 
package:flutter/…/gestures/pointer_router.dart:120
E/flutter ( 3063): #16     PointerRouter.route 
package:flutter/…/gestures/pointer_router.dart:106
E/flutter ( 3063): #17     GestureBinding.handleEvent 
package:flutter/…/gestures/binding.dart:218
E/flutter ( 3063): #18     GestureBinding.dispatchEvent 
package:flutter/…/gestures/binding.dart:198
E/flutter ( 3063): #19     GestureBinding._handlePointerEvent 
package:flutter/…/gestures/binding.dart:156
E/flutter ( 3063): #20     GestureBinding._flushPointerEventQueue 
package:flutter/…/gestures/binding.dart:102
E/flutter ( 3063): #21     GestureBinding._handlePointerDataPacket 
package:flutter/…/gestures/binding.dart:86
E/flutter ( 3063): #22     _rootRunUnary  (dart:async/zone.dart:1196:13)
E/flutter ( 3063): #23     _CustomZone.runUnary  (dart:async/zone.dart:1085:19)
E/flutter ( 3063): #24     _CustomZone.runUnaryGuarded  (dart:async/zone.dart:987:7)
E/flutter ( 3063): #25     _invoke1  (dart:ui/hooks.dart:275:10)
E/flutter ( 3063): #26     _dispatchPointerDataPacket  (dart:ui/hooks.dart:184:5)
E/flutter ( 3063):
D/RtmpConnection( 3063): handleRxPacketLoop(): Send acknowledgement window size: 5000000
D/RtmpConnection( 3063): wrote packet: RTMP Window Acknowledgment Size, size: 4
D/RtmpDecoder( 3063): readPacket(): Setting chunk size to: 8000
D/RtmpConnection( 3063): handleRxInvoke: Got result for invoked method: connect
D/RtmpConnection( 3063): createStream(): Sending releaseStream command...
D/RtmpConnection( 3063): wrote packet: RTMP Command (command: releaseStream, transaction ID: 2), size: 91
D/RtmpConnection( 3063): createStream(): Sending FCPublish command...
D/RtmpConnection( 3063): wrote packet: RTMP Command (command: FCPublish, transaction ID: 3), size: 87
D/RtmpConnection( 3063): createStream(): Sending createStream command...
D/RtmpConnection( 3063): wrote packet: RTMP Command (command: createStream, transaction ID: 4), size: 25
D/RtmpConnection( 3063): handleRxInvoke(): 'onFCPublish'
D/RtmpConnection( 3063): handleRxInvoke: Got result for invoked method: createStream
D/RtmpConnection( 3063): handleRxInvoke(): Stream ID to publish: 1
D/RtmpConnection( 3063): fmlePublish(): Sending publish command...
D/RtmpConnection( 3063): wrote packet: RTMP Command (command: publish, transaction ID: 0), size: 92
D/RtmpConnection( 3063): handleRxInvoke(): onStatus NetStream.Publish.Start
D/RtmpConnection( 3063): onMetaData(): Sending empty onMetaData...
D/RtmpConnection( 3063): wrote packet: com.github.faucamp.simplertmp.packets.Data@fb9e85f, size: 238
W/AMessage( 3063): failed to deliver message as target handler 28 is gone.
zlongCoding commented 4 years ago

如果出现这个错误,问题在于:

android.media.MediaCodec$CodecException: Error 0xfffffc0e

解决方案: 文件 flutter_rtmp/android/srs/main/java/net/ossrs/yasea/SrsEncoder.java 搜索

       MediaFormat videoFormat = MediaFormat.createVideoFormat(VCODEC, vOutWidth, vOutHeight);
       videoFormat.setInteger(MediaFormat.KEY_COLOR_FORMAT, mVideoColorFormat);
        videoFormat.setInteger(MediaFormat.KEY_MAX_INPUT_SIZE, 0);
        videoFormat.setInteger(MediaFormat.KEY_BIT_RATE, vBitrate);
        videoFormat.setInteger(MediaFormat.KEY_FRAME_RATE, VFPS);
        videoFormat.setInteger(MediaFormat.KEY_I_FRAME_INTERVAL, VGOP / VFPS);
        vencoder.configure(videoFormat, null, null, MediaCodec.CONFIGURE_FLAG_ENCODE);
        // add the video tracker to muxer.
        videoFlvTrack = flvMuxer.addTrack(videoFormat);
        videoMp4Track = mp4Muxer.addTrack(videoFormat);

然后改成:

      try {
            int formatWidth = vOutWidth;
            int formatHeight = vOutHeight;
            if ((formatWidth & 1) == 1) {
                formatWidth--;
            }
            if ((formatHeight & 1) == 1) {
                formatHeight--;
            }
        // final MediaFormat format = MediaFormat.createVideoFormat(MIME_TYPE, formatWidth, formatHeight);
            MediaFormat videoFormat = MediaFormat.createVideoFormat(VCODEC, formatWidth, formatHeight);
            videoFormat.setInteger(MediaFormat.KEY_COLOR_FORMAT, mVideoColorFormat);
            videoFormat.setInteger(MediaFormat.KEY_MAX_INPUT_SIZE, 0);
            videoFormat.setInteger(MediaFormat.KEY_BIT_RATE, vBitrate);
            videoFormat.setInteger(MediaFormat.KEY_FRAME_RATE, VFPS);
            videoFormat.setInteger(MediaFormat.KEY_I_FRAME_INTERVAL, VGOP / VFPS);
            vencoder.configure(videoFormat, null, null, MediaCodec.CONFIGURE_FLAG_ENCODE);
            videoFlvTrack = flvMuxer.addTrack(videoFormat);
            videoMp4Track = mp4Muxer.addTrack(videoFormat);
        } catch (Exception e) {
            System.out.println(e);
        }

解决的连接地址

希望对大家有所帮助。。。