Skip to content

Commit f283dab

Browse files
koumiGooglecopybara-github
authored andcommitted
chore: reorganize client. Move communication protocol and client interface to types. Move client impl to internals
PiperOrigin-RevId: 723245531
1 parent 9594a36 commit f283dab

File tree

10 files changed

+119
-97
lines changed

10 files changed

+119
-97
lines changed

web/BUILD

Lines changed: 0 additions & 52 deletions
This file was deleted.

web/internal/BUILD

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,3 +65,24 @@ ts_library(
6565
"@media_api_samples//web/types:mediacapture_transform",
6666
],
6767
)
68+
69+
ts_library(
70+
name = "meetmediaapiclient_impl",
71+
srcs = [
72+
"meetmediaapiclient_impl.ts",
73+
],
74+
deps = [
75+
":internal_meet_stream_track_impl",
76+
":internal_types",
77+
":meet_stream_track_impl",
78+
":subscribable_impl",
79+
"@media_api_samples//web/internal/channel_handlers",
80+
"@media_api_samples//web/internal/communication_protocols:default_communication_protocol",
81+
"@media_api_samples//web/types:communication_protocol_interface",
82+
"@media_api_samples//web/types:datachannels",
83+
"@media_api_samples//web/types:enums",
84+
"@media_api_samples//web/types:media_types",
85+
"@media_api_samples//web/types:meetmediaapiclient_interface",
86+
"@media_api_samples//web/types:subcribable",
87+
],
88+
)

web/internal/communication_protocols/BUILD

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,11 @@ package(default_visibility = [
1818
"@media_api_samples//web:__subpackages__",
1919
])
2020

21-
ts_library(
22-
name = "communication_protocol_interface",
23-
srcs = ["communication_protocol.ts"],
24-
)
25-
2621
ts_library(
2722
name = "default_communication_protocol",
2823
srcs = ["default_communication_protocol_impl.ts"],
2924
deps = [
30-
":communication_protocol_interface",
25+
"@media_api_samples//web/types:communication_protocol_interface",
3126
"@media_api_samples//web/types:media_types",
3227
],
3328
)

web/internal/communication_protocols/default_communication_protocol_impl.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import {MeetMediaClientRequiredConfiguration} from '../../types/mediatypes';
2424
import {
2525
MediaApiCommunicationProtocol,
2626
MediaApiCommunicationResponse,
27-
} from './communication_protocol';
27+
} from '../../types/communication_protocol';
2828

2929
const MEET_API_URL = 'https://meet.googleapis.com/v2beta/';
3030

Lines changed: 22 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -14,32 +14,12 @@
1414
* limitations under the License.
1515
*/
1616

17-
import {ChannelLogger} from './internal/channel_handlers/channel_logger';
18-
import {MediaEntriesChannelHandler} from './internal/channel_handlers/media_entries_channel_handler';
19-
import {MediaStatsChannelHandler} from './internal/channel_handlers/media_stats_channel_handler';
20-
import {ParticipantsChannelHandler} from './internal/channel_handlers/participants_channel_handler';
21-
import {SessionControlChannelHandler} from './internal/channel_handlers/session_control_channel_handler';
22-
import {VideoAssignmentChannelHandler} from './internal/channel_handlers/video_assignment_channel_handler';
2317
import {
2418
MediaApiCommunicationProtocol,
2519
MediaApiCommunicationResponse,
26-
} from './internal/communication_protocols/communication_protocol';
27-
import {DefaultCommunicationProtocolImpl} from './internal/communication_protocols/default_communication_protocol_impl';
28-
import {InternalMeetStreamTrackImpl} from './internal/internal_meet_stream_track_impl';
29-
import {
30-
InternalMediaEntry,
31-
InternalMediaLayout,
32-
InternalMeetStreamTrack,
33-
InternalParticipant,
34-
} from './internal/internal_types';
35-
import {MeetStreamTrackImpl} from './internal/meet_stream_track_impl';
36-
import {
37-
SubscribableDelegate,
38-
SubscribableImpl,
39-
} from './internal/subscribable_impl';
40-
import {MeetMediaApiClient} from './meetmediaapiclient';
41-
import {MediaApiResponseStatus} from './types/datachannels';
42-
import {MeetSessionStatus} from './types/enums';
20+
} from '../types/communication_protocol';
21+
import {MediaApiResponseStatus} from '../types/datachannels';
22+
import {MeetSessionStatus} from '../types/enums';
4323
import {
4424
CanvasDimensions,
4525
MediaEntry,
@@ -48,8 +28,25 @@ import {
4828
MeetMediaClientRequiredConfiguration,
4929
MeetStreamTrack,
5030
Participant,
51-
} from './types/mediatypes';
52-
import {Subscribable} from './types/subscribable';
31+
} from '../types/mediatypes';
32+
import {MeetMediaApiClient} from '../types/meetmediaapiclient';
33+
import {Subscribable} from '../types/subscribable';
34+
import {ChannelLogger} from './channel_handlers/channel_logger';
35+
import {MediaEntriesChannelHandler} from './channel_handlers/media_entries_channel_handler';
36+
import {MediaStatsChannelHandler} from './channel_handlers/media_stats_channel_handler';
37+
import {ParticipantsChannelHandler} from './channel_handlers/participants_channel_handler';
38+
import {SessionControlChannelHandler} from './channel_handlers/session_control_channel_handler';
39+
import {VideoAssignmentChannelHandler} from './channel_handlers/video_assignment_channel_handler';
40+
import {DefaultCommunicationProtocolImpl} from './communication_protocols/default_communication_protocol_impl';
41+
import {InternalMeetStreamTrackImpl} from './internal_meet_stream_track_impl';
42+
import {
43+
InternalMediaEntry,
44+
InternalMediaLayout,
45+
InternalMeetStreamTrack,
46+
InternalParticipant,
47+
} from './internal_types';
48+
import {MeetStreamTrackImpl} from './meet_stream_track_impl';
49+
import {SubscribableDelegate, SubscribableImpl} from './subscribable_impl';
5350

5451
// Meet only supports 3 audio virtual ssrcs. If disabled, there will be no
5552
// audio.

web/samples/BUILD

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ ts_library(
2828
name = "script",
2929
srcs = ["script.ts"],
3030
deps = [
31-
"@media_api_samples//web:meetmediaapiclient_impl",
31+
"@media_api_samples//web/internal:meetmediaapiclient_impl",
3232
"@media_api_samples//web/types:enums",
3333
"@media_api_samples//web/types:media_types",
3434
],

web/samples/script.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
import {MeetMediaApiClientImpl} from '../meetmediaapiclient_impl';
17+
import {MeetMediaApiClientImpl} from '../internal/meetmediaapiclient_impl';
1818
import {MeetSessionStatus} from '../types/enums';
1919
import {MeetStreamTrack} from '../types/mediatypes';
2020

web/types/BUILD

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,20 @@ ts_library(
4848
name = "mediacapture_transform",
4949
srcs = ["mediacapture_transform.d.ts"],
5050
)
51+
52+
ts_library(
53+
name = "communication_protocol_interface",
54+
srcs = ["communication_protocol.d.ts"],
55+
)
56+
57+
ts_library(
58+
name = "meetmediaapiclient_interface",
59+
srcs = ["meetmediaapiclient.d.ts"],
60+
deps = [
61+
":communication_protocol_interface",
62+
":datachannels",
63+
":enums",
64+
":media_types",
65+
":subcribable",
66+
],
67+
)

web/internal/communication_protocols/communication_protocol.ts renamed to web/types/communication_protocol.d.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@
2222
* An abstract communication protocol.
2323
*/
2424
export interface MediaApiCommunicationProtocol {
25+
/**
26+
* Connects to the active conference with the given SDP offer.
27+
* @param sdpOffer The SDP offer to connect to the active conference.
28+
* @return A promise that resolves to the communication response.
29+
*/
2530
connectActiveConference(
2631
sdpOffer: string,
2732
): Promise<MediaApiCommunicationResponse>;
@@ -31,5 +36,8 @@ export interface MediaApiCommunicationProtocol {
3136
* The response from the communication protocol.
3237
*/
3338
export declare interface MediaApiCommunicationResponse {
39+
/**
40+
* The WebRTC answer to the offer. Format is SDP.
41+
*/
3442
answer: string;
3543
}
Lines changed: 47 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,36 +18,72 @@
1818
* @fileoverview interface for MeetMediaApiClient.
1919
*/
2020

21-
import {MediaApiCommunicationProtocol} from './internal/communication_protocols/communication_protocol';
22-
import {MediaApiResponseStatus} from './types/datachannels';
23-
import {MeetSessionStatus} from './types/enums';
21+
import {MediaApiCommunicationProtocol} from './communication_protocol';
22+
import {MediaApiResponseStatus} from './datachannels';
23+
import {MeetSessionStatus} from './enums';
2424
import {
2525
CanvasDimensions,
2626
MediaEntry,
2727
MediaLayout,
2828
MediaLayoutRequest,
2929
MeetStreamTrack,
3030
Participant,
31-
} from './types/mediatypes';
32-
import {Subscribable} from './types/subscribable';
31+
} from './mediatypes';
32+
import {Subscribable} from './subscribable';
3333

3434
/**
35-
* Interface for the MeetMediaApiClient.
35+
* Interface for the MeetMediaApiClient. Takes a required configuration
36+
* and provides a set of subscribables to the client.
37+
* Takes a {@link MeetMediaClientRequiredConfiguration} as a constructor
38+
* parameter.
3639
*/
3740
export interface MeetMediaApiClient {
41+
/**
42+
* The status of the session. Subscribable to changes in the session status.
43+
*/
3844
readonly sessionStatus: Subscribable<MeetSessionStatus>;
45+
/**
46+
* The meet stream tracks in the meeting. Subscribable to changes in the meet
47+
* stream track collection.
48+
*/
3949
readonly meetStreamTracks: Subscribable<MeetStreamTrack[]>;
50+
/**
51+
* The media entries in the meeting. Subscribable to changes in the media
52+
* entry collection.
53+
*/
4054
readonly mediaEntries: Subscribable<MediaEntry[]>;
55+
/**
56+
* The participants in the meeting. Subscribable to changes in the
57+
* participant collection.
58+
*/
4159
readonly participants: Subscribable<Participant[]>;
60+
/**
61+
* The presenter in the meeting. Subscribable to changes in the presenter.
62+
*/
4263
readonly presenter: Subscribable<MediaEntry | undefined>;
64+
/**
65+
* The screenshare in the meeting. Subscribable to changes in the screenshare.
66+
*/
4367
readonly screenshare: Subscribable<MediaEntry[] | undefined>;
4468

69+
/**
70+
* Joins the meeting.
71+
* @param communicationProtocol The communication protocol to use. If not
72+
* provided, a default {@link MediaApiCommunicationProtocol} will be used.
73+
*/
4574
joinMeeting(
4675
communicationProtocol?: MediaApiCommunicationProtocol,
4776
): Promise<void>;
77+
78+
/**
79+
* Leaves the meeting.
80+
*/
4881
leaveMeeting(): Promise<void>;
4982

5083
/**
84+
* Applies the given media layout requests. This is required to be able to
85+
* request a video stream. Only accepts media layouts that have been
86+
* created with the {@link createMediaLayout} function.
5187
* @param requests The requests to apply.
5288
* @return A promise that resolves when the request has been accepted. NOTE:
5389
* The promise resolving on the request does not mean the layout has been
@@ -58,11 +94,11 @@ export interface MeetMediaApiClient {
5894

5995
/**
6096
* Creates a new media layout. Only media layouts that are created with this
61-
* function can be applied. Otherwise, the applyLayout function will throw an
62-
* error. Once the media layout has been created, you can construct a request
63-
* and apply it with the applyLayout function. These media layout objects are
64-
* meant to be reused (can be reassigned to a different request) but are
65-
* distinct per stream (need to be created for each stream).
97+
* function can be applied. Otherwise, the {@link applyLayout} function will
98+
* throw an error. Once the media layout has been created, you can construct a
99+
* request and apply it with the {@link applyLayout} function. These media
100+
* layout objects are meant to be reused (can be reassigned to a different
101+
* request) but are distinct per stream (need to be created for each stream).
66102
* @param canvasDimensions The dimensions of the canvas to render the layout
67103
* on.
68104
* @return The new media layout.

0 commit comments

Comments
 (0)