shaka-project / shaka-player

JavaScript player library / DASH & HLS client / MSE-EME player
Apache License 2.0
7.08k stars 1.33k forks source link

error 1007 #4307

Closed obronov closed 2 years ago

obronov commented 2 years ago

Have you read the Tutorials? yes

Have you read the FAQ and checked for duplicate open issues? yes

What version of Shaka Player are you using? 3.2.2

Please ask your question I am using cast application framework (CAF). Shaka-player shows error [cast.framework.media.ShakaPlayer] category: 6 code: 6007 [cast.debug.CastDebugLogger] [Events_CORE] {"type":"ERROR","detailedErrorCode":201,"error":{"shakaErrorCode":6007,"shakaErrorData":[{"severity":2,"category ":1,"code":1007,"data":[{}],"handled":false}]}}

I read about error 6007 in the documentation. Can you explain what causes error 1007?

joeyparrish commented 2 years ago

You can see all error code definitions in our documentation. For example:

https://shaka-player-demo.appspot.com/docs/api/shaka.util.Error.html#value:1007

You can also look them up in this interface, which just forwards you to a URL like the one above:

https://error-code-lookup-dot-shaka-player-demo.appspot.com/

Does this help?

obronov commented 2 years ago

Thanks for the answer. I read in the documentation about the code 1007. There is a short description. I do not understand him. I would like a more detailed description.

joeyparrish commented 2 years ago
LICENSE_REQUEST_FAILED 6007 number The license request failed. This could be a timeout, a network failure, or a rejection by the server.

A license request failed. There is another error embedded within to show you why:

RESPONSE_FILTER_ERROR 1007 number A response filter threw an error.

Response filters are part of our networking system. They are added by the application, and the application outside of Shaka Player is responsible for them. If a filter throws an error, the request fails.

So here, your application had a response filter installed during a license request, and while trying to process the license response, the filter threw an error.

@alekzz, what method of CAF adds response filters at the level of Shaka? Can you advise @obronov what they should look at in their application to track down this error?

obronov commented 2 years ago

@alekzz Here is my receiver.js

const context = cast.framework.CastReceiverContext.getInstance();
const playerManager = context.getPlayerManager();
const playbackConfig = new cast.framework.PlaybackConfig();

const ContentType = {
  DASH: 'application/dash+xml',
  HLS: 'application/x-mpegurl'
};
const mediaFormatID = {
  DASH: 2,
  HLS: 4
};

// Debug Logger
const castDebugLogger = cast.debug.CastDebugLogger.getInstance();
const LOG_TAG = 'MyAPP.LOG';

// Enable debug logger and show a 'DEBUG MODE' overlay at top left corner.
castDebugLogger.setEnabled(true);

// Set verbosity level for Core events.
castDebugLogger.loggerLevelByEvents = {
  'cast.framework.events.category.CORE': cast.framework.LoggerLevel.INFO,
  'cast.framework.events.EventType.MEDIA_STATUS': cast.framework.LoggerLevel.DEBUG
};

// Set verbosity level for custom tags.
castDebugLogger.loggerLevelByTags = {
    LOG_TAG: cast.framework.LoggerLevel.DEBUG,
};

playerManager.setMessageInterceptor(
  cast.framework.messages.MessageType.LOAD,
  request => {

    return new Promise((resolve, _reject) => {

      // Configure player to parse DASH content
      if (request.media.metadata.mediaFormatID == mediaFormatID.DASH) {
        request.media.contentUrl = request.media.contentUrl;
        request.media.contentType = ContentType.DASH;

        // Customize the license url for playback
        if (request.media.metadata.licenseUrl) {

          playbackConfig.licenseUrl = request.media.metadata.licenseUrl;
          playbackConfig.protectionSystem = cast.framework.ContentProtection.WIDEVINE;

          let token = request.media.metadata.token;
          let contentId = request.media.metadata.contentId;

          playbackConfig.licenseRequestHandler = requestInfo => {
            requestInfo.withCredentials = false;

            let body = {
                token: token,
                drm_info: Array.apply(null, new Uint8Array(requestInfo.content)),
                contentId: contentId
            };

            body = JSON.stringify(body);
            requestInfo.content = body;

            requestInfo.headers["Content-Type"] = "application/json";
          };
        }

      } else {
        request.media.contentType = ContentType.HLS;
        request.media.contentUrl = request.media.contentUrl;
        request.media.hlsSegmentFormat = cast.framework.messages.HlsSegmentFormat.FMP4;
        request.media.hlsVideoSegmentFormat = cast.framework.messages.HlsVideoSegmentFormat.FMP4;
      }

      // Add metadata
      let metadata = new cast.framework.messages.GenericMediaMetadata();

      metadata.title = request.media.metadata.title;
      metadata.subtitle = request.media.metadata.subtitle;

      request.media.metadata = metadata;

      resolve(request);
    });
  });

  context.start({playbackConfig: playbackConfig});
alekzz commented 2 years ago

There are 3 handlers that are used by the Shaka response filters - PlaybackConfig#manifestHandler, PlaybackConfig#licenseHandler and PlaybackConfig#segmentHandler:

https://developers.google.com/cast/docs/reference/web_receiver/cast.framework.PlaybackConfig#manifestHandler https://developers.google.com/cast/docs/reference/web_receiver/cast.framework.PlaybackConfig#licenseHandler https://developers.google.com/cast/docs/reference/web_receiver/cast.framework.PlaybackConfig#segmentHandler

I don't see any of those used in the code snippet above.

Another thing to mention - every time you change the playbackConfig object, you need to call PlayerManager#setPlaybackConfig https://developers.google.com/cast/docs/reference/web_receiver/cast.framework.PlayerManager#setPlaybackConfig

obronov commented 2 years ago

@alekzz Thanks for the hint. Added the playbackConfig.licenseHandler and the 6007 error was decided.

Now there is an error of 7000 [Cast.framework.media.shakaplayer] Category: 7 Code: 7000

From the Shaka-player documentation: The Call to Player.load () Was Interrupted by a Call to Player.unload () Or Another Call to Player.load ().

I obviously do not do Player.unload (). I launch only one video, i.e. multiple launch Player.load () does not occur. Can you tell you another possible reason for the occurrence of an error of 7000?

const context = cast.framework.CastReceiverContext.getInstance();
const playerManager = context.getPlayerManager();
const playbackConfig = new cast.framework.PlaybackConfig();

const ContentType = {
  DASH: 'application/dash+xml',
  HLS: 'application/x-mpegurl'
};
const mediaFormatID = {
  DASH: 2,
  HLS: 4
};

// Debug Logger
const castDebugLogger = cast.debug.CastDebugLogger.getInstance();
const LOG_TAG = 'MyAPP.LOG';

// Enable debug logger and show a 'DEBUG MODE' overlay at top left corner.
castDebugLogger.setEnabled(true);

// Show debug overlay
// castDebugLogger.showDebugLogs(true);

// Set verbosity level for Core events.
castDebugLogger.loggerLevelByEvents = {
  'cast.framework.events.category.CORE': cast.framework.LoggerLevel.INFO,
  'cast.framework.events.EventType.MEDIA_STATUS': cast.framework.LoggerLevel.DEBUG
};

// Set verbosity level for custom tags.
castDebugLogger.loggerLevelByTags = {
    LOG_TAG: cast.framework.LoggerLevel.DEBUG,
};

playerManager.setMessageInterceptor(
  cast.framework.messages.MessageType.LOAD,
  request => {
    return new Promise((resolve, _reject) => {

      // Configure player to parse DASH content
      if (request.media.metadata.mediaFormatID == mediaFormatID.DASH) {
        request.media.contentUrl = request.media.contentUrl;
        request.media.contentType = ContentType.DASH;

        // Customize the license url for playback
        if (request.media.metadata.licenseUrl) {
          playbackConfig.licenseUrl = request.media.metadata.licenseUrl;
          playbackConfig.protectionSystem = cast.framework.ContentProtection.WIDEVINE;

          let token = request.media.metadata.token;
          let contentId = request.media.metadata.contentId;

          playbackConfig.licenseRequestHandler = requestInfo => {
            requestInfo.withCredentials = false;

            let body = {
                token: token,
                drm_info: Array.apply(null, new Uint8Array(requestInfo.content)),
                contentId: contentId
            };

            body = JSON.stringify(body);
            requestInfo.content = body;

            requestInfo.headers["Content-Type"] = "application/json";
          };
        }

      } else {
        request.media.contentType = ContentType.HLS;
        request.media.contentUrl = request.media.contentUrl;
        request.media.hlsSegmentFormat = cast.framework.messages.HlsSegmentFormat.FMP4;
        request.media.hlsVideoSegmentFormat = cast.framework.messages.HlsVideoSegmentFormat.FMP4;
      }

      castDebugLogger.warn(LOG_TAG, 'Playable URL:', request.media.contentUrl);

      // Add metadata
      let metadata = new cast.framework.messages.GenericMediaMetadata();

      metadata.title = request.media.metadata.title;
      metadata.subtitle = request.media.metadata.subtitle;

      request.media.metadata = metadata;

      resolve(request);

    });
  });

  playbackConfig.licenseHandler = data => {
    return new Promise((resolve, _reject) => {
      resolve(new Uint8Array(data));
    });
  };

  context.start({playbackConfig: playbackConfig});
obronov commented 2 years ago

It is noticed that one of the channels with drm starts up for me, but the video is not shown. Only audio works.

Other channels with drm do not work. An error: [Cast.framework.media.shakaplayer] Category: 7 Code: 7000

In the console, only mpd files are uploaded to the "network". Packages with video and audio do not come.

Can you suggest the reason for this behaviour?

joeyparrish commented 2 years ago

I obviously do not do Player.unload (). I launch only one video, i.e. multiple launch Player.load () does not occur. Can you tell you another possible reason for the occurrence of an error of 7000?

No, that should be the only reason. It's a very simple error code. It only fires from one place, load(). It can be triggered by an interruption from load(), unload(), detach(), or destroy(). I assume you aren't calling any of those?

Are your load() calls all handled by the Cast SDK through the LOAD message? Or do you directly interact with a shaka.Player instance somewhere in your custom receiver app?

obronov commented 2 years ago

I assume you aren't calling any of those?

I use only interceptor playerManager.setMessageInterceptor( cast.framework.messages.MessageType.LOAD

Are your load() calls all handled by the Cast SDK through the LOAD message?

Processed via Cast SDK

joeyparrish commented 2 years ago

Let me discuss with @alekzz and get back to you. I'm stumped at the moment.

github-actions[bot] commented 2 years ago

@obronov Does this answer all your questions? If so, would you please close the issue?

joeyparrish commented 2 years ago

Please disregard the bot. I've asked it not to close the issue.

obronov commented 2 years ago

We were able to start the video. However, only videos with codecs="avc1.4D401F" work.

Examples of non-working codecs:

codecs="avc1.4D4029"
codecs="avc1.64001E"
codecs="avc1.640020"

We tested the shaka player separately and the video with all codecs works there. Obviously a problem with google cast.

Thanks for the help.

obronov commented 2 years ago

Now only videos with the “avc1.4D401F” codec work for me. Videos with codecs “avc1.64001E”, “avc1.640020”, “avc1.4D4029” do not work. Due to the fact that google cast supports the "avc1.4D401F" codec, I want to replace the non-working codecs in the manifest with "avc1.4D401F".

From the google cast documentation:

manifestHandler

Handler to process manifest data. The handler is passed the manifest, and returns the modified manifest.

Therefore, in manifestHandler I replace the line with codecs.

playbackConfig.manifestHandler = data => {
 updateManifest = function(manifest) {
  return manifest.replace(/avc1.(\w*)/gi, 'avc1.4D401F');
 };
 const newManifest = updateManifest(data);
  return new Promise((resolve, _reject) => {
   resolve(newManifest);
  });
};

I made sure that the function works and really changes the values in the manifest. Tested replacing different parts of the manifest. However, when I try to change the codec, it does not help. Maybe something else needs to be changed along with the codec?

const context = cast.framework.CastReceiverContext.getInstance();
const playerManager = context.getPlayerManager();
const playbackConfig = new cast.framework.PlaybackConfig();

cast.framework.CastReceiverOptions.useLegacyDashSupport = true;

const ContentType = {
  DASH: 'application/dash+xml',
  HLS: 'application/x-mpegurl'
};
const mediaFormatID = {
  DASH: 2,
  HLS: 4
};

// Debug Logger
const castDebugLogger = cast.debug.CastDebugLogger.getInstance();
const LOG_TAG = 'MyAPP.LOG';

// Enable debug logger and show a 'DEBUG MODE' overlay at top left corner.
castDebugLogger.setEnabled(true);

// Show debug overlay
//castDebugLogger.showDebugLogs(true);

// Set verbosity level for Core events.
castDebugLogger.loggerLevelByEvents = {
  'cast.framework.events.category.CORE': cast.framework.LoggerLevel.INFO,
  'cast.framework.events.EventType.MEDIA_STATUS': cast.framework.LoggerLevel.DEBUG
};

// Set verbosity level for custom tags.
castDebugLogger.loggerLevelByTags = {
    LOG_TAG: cast.framework.LoggerLevel.DEBUG,
};

playerManager.setMessageInterceptor(
  cast.framework.messages.MessageType.LOAD,
  request => {
    return new Promise((resolve, _reject) => {

      // Configure player to parse DASH content
      if (request.media.metadata.mediaFormatID == mediaFormatID.DASH) {
        request.media.contentUrl = request.media.contentUrl;
        request.media.contentType = ContentType.DASH;

        // Customize the license url for playback
        if (request.media.metadata.licenseUrl) {
          playbackConfig.protectionSystem = cast.framework.ContentProtection.WIDEVINE;
          playbackConfig.licenseUrl = request.media.metadata.licenseUrl;

          let token = request.media.metadata.token;
          let contentId = request.media.metadata.contentId;

          playbackConfig.licenseRequestHandler = requestInfo => {
            let body = {
                token: token,
                drm_info: Array.apply(null, new Uint8Array(requestInfo.content)),
                contentId: contentId
            };

            body = JSON.stringify(body);
            requestInfo.content = body;

            requestInfo.headers["Content-Type"] = "application/json";
          };
        }

      } else {
        request.media.contentType = ContentType.HLS;
        request.media.contentUrl = request.media.contentUrl;
        request.media.hlsSegmentFormat = cast.framework.messages.HlsSegmentFormat.TS;
        request.media.hlsVideoSegmentFormat = cast.framework.messages.HlsVideoSegmentFormat.MPEG2_TS;
      }

      castDebugLogger.warn(LOG_TAG, 'Playable URL:', request.media.contentUrl);

      // Add metadata
      let metadata = new cast.framework.messages.GenericMediaMetadata();

      metadata.title = request.media.metadata.title;
      metadata.subtitle = request.media.metadata.subtitle;

      request.media.metadata = metadata;

      resolve(request);

    });
  });

  playbackConfig.licenseHandler = data => {
    return new Promise((resolve, _reject) => {
      resolve(new Uint8Array(data));
    });
  };

  playbackConfig.manifestHandler = data => {
    updateManifest = function(manifest) {
      return manifest.replace(/avc1.(\w*)/gi, 'avc1.4D401F');
    };

    const newManifest = updateManifest(data);

    return new Promise((resolve, _reject) => {
      resolve(newManifest);
    });
  };

  context.start({playbackConfig: playbackConfig});
joeyparrish commented 2 years ago

We tested the shaka player separately and the video with all codecs works there. Obviously a problem with google cast.

This is not true. Codec support is a matter for the platform, not the player. The Cast device likely does not actually support all of those various profiles of H264.

Now only videos with the “avc1.4D401F” codec work for me. Videos with codecs “avc1.64001E”, “avc1.640020”, “avc1.4D4029” do not work. Due to the fact that google cast supports the "avc1.4D401F" codec, I want to replace the non-working codecs in the manifest with "avc1.4D401F".

That is not a good idea. Those codec strings convey real information to the platform about the profile of the codec used, and the hardware decoders may not support every profile, bitrate, framerate, etc. If the platform says it does not support a specific codec string, you should trust it. Changing the codec string to lie to the platform is only likely to get you decoder failures and performance problems that could have been avoided by the platform negotiation and filtering mechanisms already built into the player.

github-actions[bot] commented 2 years ago

@obronov Does this answer all your questions? If so, would you please close the issue?

github-actions[bot] commented 2 years ago

Closing due to inactivity. If this is still an issue for you or if you have further questions, the OP can ask shaka-bot to reopen it by including @shaka-bot reopen in a comment.