Skip to content

Commit

Permalink
chore(player-with-timed-metadata.html): resolve conflict with player-…
Browse files Browse the repository at this point in the history
…with-timed-metadata.html
  • Loading branch information
thomasjammet committed Mar 4, 2024
2 parents 13aef9d + b2e7b3c commit ead33e5
Show file tree
Hide file tree
Showing 10 changed files with 24 additions and 14 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ import * as WebRTC from '@ceeblue/webrtc-client';
> }
> }
> ```
> - To avoid potential issues with backward compatibility or problems on iOS when using `navigator.mediaDevices.getUserMedia`, we recommend including the [WebRTC adapter](https://github.com/webrtcHacks/adapter) in the final project. This often mitigates common compatibility issues on certain older devices.
### Publish a stream
Expand Down
2 changes: 1 addition & 1 deletion examples/player-with-timed-metadata.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ <h2>WebRTC Client Timed Metadata Player Example</h2>

<script type="module">
import { NetAddress, Util } from "https://cdn.jsdelivr.net/npm/@ceeblue/web-utils@1.1.0/dist/web-utils.min.js";
import { Player } from "/dist/webrtc-client.js";
import { Player } from "../dist/webrtc-client.js";

const logs = document.getElementById("metadata");
const videoElement = document.getElementById('video');
Expand Down
2 changes: 0 additions & 2 deletions examples/player.html
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,6 @@ <h3 class="text-center">WebRTC Client Player Example</h3>
</div>
</div>

<!-- Avoid naming issues with Apple devices : -->
<script src="https://cdn.jsdelivr.net/npm/webrtc-adapter/out/adapter.js"></script>
<script type="module">
import { NetAddress, Util } from "https://cdn.jsdelivr.net/npm/@ceeblue/web-utils@1.1.0/dist/web-utils.min.js";
import { Player, HTTPConnector, WSController, VERSION } from "../dist/webrtc-client.min.js";
Expand Down
1 change: 0 additions & 1 deletion examples/streamer.html
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,6 @@ <h4 class="text-center font-weight-bold">On Air</h4>
<!--<script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>-->
<!-- production version, optimized for size and speed -->
<script src="https://cdn.jsdelivr.net/npm/vue@2"></script>
<script src="https://cdn.jsdelivr.net/npm/webrtc-adapter/out/adapter.js"></script>
<script type="module">
import { NetAddress, Util } from "https://cdn.jsdelivr.net/npm/@ceeblue/web-utils@1.1.0/dist/web-utils.min.js";
import { Streamer, HTTPConnector, WSController, VERSION } from "../dist/webrtc-client.js";
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ceeblue/webrtc-client",
"version": "1.2.0",
"version": "1.3.0",
"description": "Ceeblue WebRTC Client",
"keywords": [
"webrtc",
Expand Down
2 changes: 0 additions & 2 deletions src/abr/ABRAbstract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,6 @@ export abstract class ABRAbstract extends EventEmitter implements ABRParams, ILo
private _maximum: number;
private _minimum: number;
private _stream?: MediaStream;
private _enabled: boolean;
/**
* Build the ABR implementation, call {@link compute} to use it
* @param params ABR parameters
Expand All @@ -156,7 +155,6 @@ export abstract class ABRAbstract extends EventEmitter implements ABRParams, ILo
this._minimum = init.minimum;
this._maximum = init.maximum;
this._stream = stream;
this._enabled = true;
}

/**
Expand Down
20 changes: 19 additions & 1 deletion src/connectors/SIPConnector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import { Connect, EventEmitter, NetAddress, SDP, Util } from '@ceeblue/web-utils';
import { ConnectionInfos, IConnector } from './IConnector';

const isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);

/**
* SIPConnector is a common abstract class for negotiating a new RTCPeerConnection connection
* with the server.
Expand Down Expand Up @@ -217,7 +219,7 @@ export abstract class SIPConnector extends EventEmitter implements IConnector {
}
// Start the RTCPeerConnection and create an offer
try {
this._peerConnection = new RTCPeerConnection(iceServer ? { iceServers: [iceServer] } : undefined);
this._peerConnection = new RTCPeerConnection({ iceServers: [iceServer] });
} catch (e) {
this.close('RTCPeerConnection failed, ' + Util.stringify(e));
return;
Expand All @@ -235,6 +237,22 @@ export abstract class SIPConnector extends EventEmitter implements IConnector {
};
}

// Add transceivers for Safari
// This is necessary for Safari to handle the audio and video tracks correctly
if (isSafari) {
if (!this._stream) {
this._peerConnection.addTransceiver('audio', { direction: 'recvonly' });
this._peerConnection.addTransceiver('video', { direction: 'recvonly' });
} else {
const transceivers = this._peerConnection.getTransceivers();
for (const transceiver of transceivers) {
if (transceiver.receiver.track.kind === 'audio' || transceiver.receiver.track.kind === 'video') {
transceiver.direction = 'sendonly';
}
}
}
}

let sdp: string;
this._peerConnection
.createOffer({ offerToReceiveAudio: !this._stream, offerToReceiveVideo: !this._stream })
Expand Down
2 changes: 0 additions & 2 deletions src/mbr/MBRAbstract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ export abstract class MBRAbstract implements MBRParams, ILog {
private _maximumUpDelay: number;
private _testTime: number;
private _appreciationTime?: number;
private _enabled: boolean;

/**
* Build the MBR implementation, call {@link compute} to use it
Expand All @@ -88,7 +87,6 @@ export abstract class MBRAbstract implements MBRParams, ILog {
this._maximumUpDelay = init.maximumUpDelay;
this._upDelay = 0;
this._testTime = 0;
this._enabled = true;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/metadata/StreamMetadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const sortByMAXBPS = (track1: MTrack, track2: MTrack) => track2.maxbps - track1.
* - the list of tracks and their properties,
* - the list of availables sources and their properties,
* @example
* const streamMetadata = new StreamMetadata(Util.metadataURL(host, streamName));
* const streamMetadata = new StreamMetadata(Connect.buildURL(host, streamName));
* streamMetadata.onMetadata = metadata => {
* console.log(metadata);
* }
Expand Down

0 comments on commit ead33e5

Please sign in to comment.