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

Add ABR #76

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@

name: Run Test Cases And Publish Package

on:
push:
branches:
- main
on: [pull_request]

schedule:
- cron: '0 0 * * 2'

jobs:
build:
Expand Down
12 changes: 9 additions & 3 deletions example/SampleProject/integration_test/test_play.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@

import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:integration_test/integration_test.dart';
import 'test_helper.dart';
Expand All @@ -11,18 +11,24 @@ void main() {
// Launch the app.
await launchApp(tester);

await tester.pumpAndSettle();

// Enter the server URL.
await enterServerUrl(tester, 'wss://test.antmedia.io:5443/24x7test/websocket');

await tester.pumpAndSettle();

// Tap the 'Play' button.
await tester.tap(find.text('Play'));
await tester.pumpAndSettle();

// Enter Room ID and tap OK.
await enterRoomId(tester, '24x7test');
await tester.pumpAndSettle(const Duration(seconds: 10));
await tester.pumpAndSettle(const Duration(seconds: 15));

// Verify the content of the SnackBar.
expect(find.textContaining('Received: '), findsOneWidget);
final callEndIcon = find.byIcon(Icons.call_end);
await tester.tap(callEndIcon);
await tester.pumpAndSettle();
});
}
30 changes: 24 additions & 6 deletions example/SampleProject/lib/play.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// ignore_for_file: must_be_immutable, avoid_print

import 'dart:core';
import 'dart:math';

import 'package:ant_media_flutter/ant_media_flutter.dart';
import 'package:flutter/material.dart';
Expand All @@ -25,7 +26,9 @@ class Play extends StatefulWidget {
class _PlayState extends State<Play> {
final RTCVideoRenderer _localRenderer = RTCVideoRenderer();
final RTCVideoRenderer _remoteRenderer = RTCVideoRenderer();
List<String> abrList = ['Automatic'];
List<String> abrList = [];
String _currentAbr = 'Automatic';

bool _inCalling = false;
bool _isPaused = false;
bool _isFullScreen = false;
Expand Down Expand Up @@ -142,12 +145,22 @@ class _PlayState extends State<Play> {
}),
widget.iceServers,
(command, mapData) {
abrList = ['Automatic'];
if (command == 'streamInformation') {
if (command == 'notification') {
if(mapData["definition"] == "play_started"){
setState(() {
_inCalling = true;
});
AntMediaFlutter.anthelper?.getStreamInfo(widget.id);
}
}
else if (command == 'streamInformation') {
abrList = ['Automatic'];
print(mapData['streamInfo']);
mapData['streamInfo'].forEach((abrSetting) =>
{abrList.add(abrSetting['streamHeight'].toString())});

setState(() {
mapData['streamInfo'].forEach((abrSetting) =>
{abrList.add(abrSetting['streamHeight'].toString())});
abrList;
});
}
});
Expand Down Expand Up @@ -186,10 +199,15 @@ class _PlayState extends State<Play> {
);
}).toList(),
onChanged: (streamHeight) {
if (streamHeight == 'Automatic') streamHeight = '0';
if (streamHeight == 'Automatic')
streamHeight = '0';
AntMediaFlutter.anthelper?.forceStreamQuality(
widget.id, int?.parse(streamHeight.toString()));
setState(() {
_currentAbr = (streamHeight == '0' ? 'Automatic' : streamHeight)!;
});
},
value: _currentAbr,
)
]))
: null,
Expand Down
9 changes: 8 additions & 1 deletion lib/src/helpers/helper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,7 @@ class AntHelper {
print("$command $mapData");
break;
}
callbacks(command, mapData);
}

Future<void> connect(AntMediaType type) async {
Expand Down Expand Up @@ -667,7 +668,13 @@ class AntHelper {
};
_sendAntMedia(request);
}

void getStreamInfo(String streamId){
final request = {
'command': 'getStreamInfo',
'streamId': streamId,
};
_sendAntMedia(request);
}
// Force stream into a specific quality
void forceStreamQuality(String streamId, int resolution) {
final request = {
Expand Down