Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

shaka-player dash can‘t use p2p #435

Closed
hkchenhongyi opened this issue Nov 14, 2024 · 10 comments · Fixed by #442
Closed

shaka-player dash can‘t use p2p #435

hkchenhongyi opened this issue Nov 14, 2024 · 10 comments · Fixed by #442

Comments

@hkchenhongyi
Copy link

shaka-player dash type can‘t use p2p

I use shaka-player hls drm and it works fine with p2p
But I use it to play dash format files.
It plays fine, but it won't work with p2p?
The loader is also not using p2p-media-loader!

@mrlika
Copy link
Member

mrlika commented Nov 17, 2024

Hi! Could you please share more details, specifically the stream that's not playing on your end? This will help us investigate and resolve the issue effectively.

@hkchenhongyi
Copy link
Author

this dash config can't use p2p!

<?xml
version="1.0" encoding="UTF-8"?>
<MPD xmlns="urn:mpeg:dash:schema:mpd:2011" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xlink="http://www.w3.org/1999/xlink" xsi:schemaLocation="urn:mpeg:dash:schema:mpd:2011 DASH-MPD.xsd" xmlns:cenc="urn:mpeg:cenc:2013" minBufferTime="PT2S" type="static" profiles="urn:mpeg:dash:profile:isoff-on-demand:2011" mediaPresentationDuration="PT1204S">
    <Period>
        <AdaptationSet contentType="video" maxWidth="" maxHeight="" frameRate="25" subsegmentAlignment="true" par="40:17">
            <Representation bandwidth="11437024" codecs="avc1.640033" mimeType="video/mp4" sar="1:1">
                <BaseURL>https://XXX</BaseURL>
                <SegmentBase indexRange="1016-3939">
                    <Initialization range="0-1015"/>
                </SegmentBase>
            </Representation>
        </AdaptationSet>
        <AdaptationSet contentType="audio" subsegmentAlignment="true">
            <Role schemeIdUri="urn:mpeg:dash:role:2011"/>
            <Representation bandwidth="45899" codecs="mp4a.40.5" mimeType="audio/mp4">
                <AudioChannelConfiguration schemeIdUri="urn:mpeg:dash:23003:3:audio_channel_configuration:2011"/>
                <BaseURL>https://XXX</BaseURL>
                <SegmentBase indexRange="956-3879">
                    <Initialization range="0-955"/>
                </SegmentBase>
            </Representation>
        </AdaptationSet>
    </Period>
</MPD>

shaka drm
url use:
data:text/plain;base64,XXX。 Can't be used p2p
https://XXX Can be used p2p

#EXTM3U
#EXT-X-MEDIA:TYPE=AUDIO,URI="XXX",GROUP-ID="default-audio-group",NAME="stream_0",AUTOSELECT=YES,CHANNELS="2"
#EXT-X-STREAM-INF:BANDWIDTH=4710135,CODECS="avc1.640028,mp4a.40.2",AUDIO="default-audio-group"
XXX

@DimaDemchenko
Copy link
Contributor

DimaDemchenko commented Nov 19, 2024

@hkchenhongyi
From your provided example it's unclear what went wrong. Please, provide us more information about your issue.
We need to know how do you set up Shaka player and DRM Encryption.

Below, I’ll provide a simple example of how to integrate Shaka Player with P2P Media Loader and configure DRM.

Shaka DRM Configuration Documentation

<!doctype html>
<html>
  <head>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/shaka-player/4.12.1/shaka-player.compiled.js"></script>

    <script type="importmap">
      {
        "imports": {
          "p2p-media-loader-core": "https://cdn.jsdelivr.net/npm/p2p-media-loader-core@^2/dist/p2p-media-loader-core.es.min.js",
          "p2p-media-loader-shaka": "https://cdn.jsdelivr.net/npm/p2p-media-loader-shaka@^2/dist/p2p-media-loader-shaka.es.min.js"
        }
      }
    </script>

    <script type="module">
      import { ShakaP2PEngine } from "p2p-media-loader-shaka";

      ShakaP2PEngine.registerPlugins();

      async function init() {
        const video = document.getElementById("video");

        const player = new shaka.Player(video);

        const shakaP2PEngine = new ShakaP2PEngine({
          core: {
            swarmId: "swarm",
          },
        });

        shakaP2PEngine.addEventListener("onPeerConnect", (params) => {
          console.log("Peer connected:", params.peerId);
        });

        shakaP2PEngine.addEventListener(
          "onChunkDownloaded",
          (bytesLength, downloadSource, peerId) => {
            console.log(
              `Downloaded ${bytesLength} bytes from ${downloadSource} ${peerId ? "from peer " + peerId : "from server"}`,
            );
          },
        );

        shakaP2PEngine.bindShakaPlayer(player);

        player.configure({
          drm: {
            servers: {
              "com.widevine.alpha":
                "https://cwip-shaka-proxy.appspot.com/no_auth",
            },
          },
        });

        await player.load(
          "https://cdn.bitmovin.com/content/assets/art-of-motion_drm/mpds/11331.mpd",
        );
      }

      document.addEventListener("DOMContentLoaded", init);
    </script>
  </head>

  <body>
    <video
      autoplay
      controls
      data-shaka-player
      id="video"
      style="width: 100%; height: 100%"
    ></video>
  </body>
</html>

@hkchenhongyi
Copy link
Author

shaka drm
m3u8 URL used data:text/plain;base64,XXX can't enable p2p

shaka dash
my xml config can play! but no enable p2p!

@DimaDemchenko
Copy link
Contributor

@hkchenhongyi
What Shaka player version do you use?

@hkchenhongyi
Copy link
Author

@hkchenhongyi What Shaka player version do you use?

4.11.11

@DimaDemchenko
Copy link
Contributor

@hkchenhongyi What Shaka player version do you use?

4.11.11

shakaP2PEngine.addEventListener(
          "onChunkDownloaded",
          (bytesLength, downloadSource, peerId) => {
            console.log(
              `Downloaded ${bytesLength} bytes from ${downloadSource} ${peerId ? "from peer " + peerId : "from server"}`,
            );
          },
        );

Could you subscribe to this event and check if there are any logs indicating a download through HTTP

@hkchenhongyi
Copy link
Author

None of the loaders worked!
I checked the developer tools
The one that loads the segments is shaka, not the p2p loader

QQ_1732036937050

@DimaDemchenko DimaDemchenko linked a pull request Nov 21, 2024 that will close this issue
@DimaDemchenko
Copy link
Contributor

Hi @hkchenhongyi,

We’ve added support for data URLs in the upcoming release, which will address the issue you’ve reported. Please stay tuned as the new version will be released soon.

Thank you for your patience and understanding!

Best regards

@hkchenhongyi
Copy link
Author

Hi @hkchenhongyi,

We’ve added support for data URLs in the upcoming release, which will address the issue you’ve reported. Please stay tuned as the new version will be released soon.

Thank you for your patience and understanding!

Best regards

ok! thank you very much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants