johnvuko / flutter_cast

Dart package to discover and connect with Chromecast devices
MIT License
46 stars 38 forks source link

InvalidProtocolBufferException for GET_STATUS request to the cast receiver #31

Open RaghuMudem opened 2 years ago

RaghuMudem commented 2 years ago

Implementing the cast sender client with Flutter program. We also have the custom cast receiver in running in the chromecast. We are having the problem while querying for "GET_STATUS" to the cast receiver to know the current status of the media playback. This same request command is working for most of the videos but having problem for few videos with short length(10 ~ 20 Minutes duration). We don't have idea for the reason. Appriciates supportive response.

Request from client:

{type: GET_STATUS, mediaSessionId: 1, requestId: 106}

Error in Response:


I/flutter ( 1578): ----------------FIREBASE CRASHLYTICS----------------
I/flutter ( 1578): The following exception was thrown A non-fatal error for functional_error and from_flutter is false event_scope is Unhandled Exception:
I/flutter ( 1578): InvalidProtocolBufferException: While parsing a protocol message, the input ended unexpectedly
I/flutter ( 1578): in the middle of a field.  This could mean either than the
I/flutter ( 1578): input has been truncated or that an embedded message
I/flutter ( 1578): misreported its own length.
I/flutter ( 1578): 
I/flutter ( 1578): crash in main.dart > from_flutter: false
I/flutter ( 1578): 
I/flutter ( 1578): #0      CodedBufferReader._checkLimit (package:protobuf/src/protobuf/coded_buffer_reader.dart:58:7)
I/flutter ( 1578): #1      CodedBufferReader.readBytes (package:protobuf/src/protobuf/coded_buffer_reader.dart:128:5)
I/flutter ( 1578): #2      CodedBufferReader.readString (package:protobuf/src/protobuf/coded_buffer_reader.dart:133:39)
I/flutter ( 1578): #3      _mergeFromCodedBufferReader (package:protobuf/src/protobuf/coded_buffer.dart:59:47)
I/flutter ( 1578): #4      GeneratedMessage.mergeFromBuffer (package:protobuf/src/protobuf/generated_message.dart:185:5)
I/flutter ( 1578): #5      new CastMessage.fromBuffer (package:cast/cast_channel/cast_channel.pb.dart:61:129)
I/flutter ( 1578): #6      CastSocket._startListening.<anonymous closure> (package:cast/socket.dart:48:41)
I/flutter ( 1578): #7      _rootRunUnary (dart:async/zone.dart:1434:47)
I/flutter ( 1578): #8      _CustomZone.runUnary (dart:async/zone.dart:1335:19)
I/flutter ( 1578): #9      _CustomZone.runUnaryGuarded (dart:async/zone.dart:1244:7)
I/flutter ( 1578): #10     _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:341:11)
I/flutter ( 1578): #11     _BufferingStreamSubscription._add (dart:async/stream_impl.dart:271:7)
I/flutter ( 1578): #12     
I/flutter ( 1578): ----------------------------------------------------
I/flutter ( 1578): Error From Outside Flutter InvalidProtocolBufferException: Protocol message tag had invalid wire type.
I/flutter ( 1578): ----------------FIREBASE CRASHLYTICS----------------
I/flutter ( 1578): The following exception was thrown A non-fatal error for functional_error and from_flutter is false event_scope is Unhandled Exception:
I/flutter ( 1578): InvalidProtocolBufferException: Protocol message tag had invalid wire type.
I/flutter ( 1578): 
I/flutter ( 1578): crash in main.dart > from_flutter: false
I/flutter ( 1578): 
I/flutter ( 1578): #0      UnknownFieldSet.mergeFieldFromBuffer (package:protobuf/src/protobuf/unknown_field_set.dart:79:9)
I/flutter ( 1578): #1      _mergeFromCodedBufferReader (package:protobuf/src/protobuf/coded_buffer.dart:42:38)
I/flutter ( 1578): #2      GeneratedMessage.mergeFromBuffer (package:protobuf/src/protobuf/generated_message.dart:185:5)
I/flutter ( 1578): #3      new CastMessage.fromBuffer (package:cast/cast_channel/cast_channel.pb.dart:61:129)
I/flutter ( 1578): #4      CastSocket._startListening.<anonymous closure> (package:cast/socket.dart:48:41)
I/flutter ( 1578): #5      _rootRunUnary (dart:async/zone.dart:1434:47)
I/flutter ( 1578): #6      _CustomZone.runUnary (dart:async/zone.dart:1335:19)
I/flutter ( 1578): #7      _CustomZone.runUnaryGuarded (dart:async/zone.dart:1244:7)
I/flutter ( 1578): #8      _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:341:11)
I/flutter ( 1578): #9      _BufferingStreamSubscription._add (dart:async/stream_impl.dart:271:7)
I/flutter ( 1578): #10     _SyncStreamControllerDispatch._sendData (dart:async/stream_controller.dart:774:19)
I/flutter ( 1578): #11     _StreamController._add (dart:async/stream_controller.dart:648:7)
I/flutter ( 1578): #12     _StreamController.add (dart:asy
I/flutter ( 1578): ----------------------------------------------------

Expected correct resoponse:

{
   "type":"MEDIA_STATUS",
   "status":[
      {
         "mediaSessionId":3,
         "playbackRate":1,
         "playerState":"PLAYING",
         "currentTime":1756.7264008522034,
         "supportedMediaCommands":12495,
         "volume":{
            "level":1,
            "muted":false
         },
         "activeTrackIds":[
            1
         ],
         "media":{
            "..."
         },
         "textTrackStyle":{
            "fontScale":1.22,
            "backgroundColor":#FFFFFF00,
            "edgeType":"OUTLINE",
            "edgeColor":#000000FF,
            "windowType":"NORMAL",
            "fontFamily":"sans"
         }
      }
   ]
}

Here is my flutter doctor result:

Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 2.10.3, on Microsoft Windows [Version 10.0.22000.856], locale en-NL)
[!] Android toolchain - develop for Android devices (Android SDK version 33.0.0-rc1)
    X cmdline-tools component is missing
      Run `path/to/sdkmanager --install "cmdline-tools;latest"`
      See https://developer.android.com/studio/command-line for more details.
    X Android license status unknown.
      Run `flutter doctor --android-licenses` to accept the SDK licenses.
      See https://flutter.dev/docs/get-started/install/windows#android-setup for more details.
[√] Chrome - develop for the web
[X] Visual Studio - develop for Windows
    X Visual Studio not installed; this is necessary for Windows development.
      Download at https://visualstudio.microsoft.com/downloads/.
      Please install the "Desktop development with C++" workload, including all of its default components
[√] Android Studio (version 2021.1)
[√] Connected device (4 available)
[√] HTTP Host Availability

Cast library version: cast: ^1.1.1

kalismeras61 commented 4 weeks ago

@RaghuMudem did you find solution ? i want to get current duration ?