Skip to content

Commit

Permalink
Releases/v0.3.1 (#22)
Browse files Browse the repository at this point in the history
## Improvements

* fix: Player should always request redundant_streams (#19)
* feat: Set player software name as `mux-player-android` (#21)



Co-authored-by: Emily Dixon <[email protected]>
Co-authored-by: Tomislav Kordic <[email protected]>
Co-authored-by: GitHub <[email protected]>
  • Loading branch information
3 people authored Nov 29, 2023
1 parent e86b60d commit d1593fd
Show file tree
Hide file tree
Showing 310 changed files with 4,793 additions and 9 deletions.
74 changes: 74 additions & 0 deletions .github/workflows/saucelabs-tests-push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: Test with Sauce Labs

on:
push:

env:
SAUCE_USERNAME: ${{secrets.SAUCE_USERNAME}}
SAUCE_ACCESS_KEY: ${{secrets.SAUCE_ACCESS_KEY}}

#concurrency:
# group: sauce-labs
# cancel-in-progress: true

jobs:
build:
name: Build Test APKs
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
- name: Build automated tests
uses: gradle/[email protected]
with:
arguments: automatedtests:assembleDebug :automatedtests:assembleDebugAndroidTest
- name: Upload Test APKs
uses: actions/upload-artifact@v3
with:
name: automated-test-apks
path: |
automatedtests/build/outputs/apk/androidTest/debug/automatedtests-debug-androidTest.apk
automatedtests/build/outputs/apk/debug/automatedtests-debug.apk
test:
name: Run Sauce Labs Tests
runs-on: ubuntu-latest
needs: build

strategy:
max-parallel: 2

env:
app_artifact: automatedtests\/build\/outputs\/apk\/debug\/automatedtests-debug.apk
test_artifact: automatedtests\/build\/outputs\/apk\/androidTest\/debug\/automatedtests-debug-androidTest.apk
app_apk: debug\/automatedtests-debug.apk
test_apk: androidTest\/debug\/automatedtests-debug-androidTest.apk

steps:
- uses: actions/checkout@v3
- name: Download Test APKS
uses: actions/download-artifact@v3
with:
name: automated-test-apks
- name: Build sauce config file
run: |
sed -E \
-e 's/BUILD_LABEL/debug/g' \
-e 's/APP_APK/${{ env.app_apk }}/g' \
-e 's/TEST_APK/${{ env.test_apk }}/g' \
.sauce/template.yml > .sauce/conf.yml
- name: Dump Generated Sauce Conf
run: cat .sauce/conf.yml
- name: Run Saucelabs Test
uses: saucelabs/saucectl-run-action@v3
env:
GITHUB_TOKEN: ${{ github.token }}
with:
sauce-username: ${{ secrets.SAUCE_USERNAME }}
sauce-access-key: ${{ secrets.SAUCE_ACCESS_KEY }}
config-file: .sauce/conf.yml
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,6 @@ google-services.json

# Android Profiling
*.hprof

# automatedtests results
automatedtests/automated_test_results/**
28 changes: 28 additions & 0 deletions .sauce/template.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
apiVersion: v1alpha
kind: espresso
sauce:
region: us-west-1
concurrency: 1
retries: 3

metadata:
#name: Runs from GHA
tags:
- saucectrl-runner
build: Release BUILD_LABEL
espresso:
app: APP_APK
testApp: TEST_APK
suites:
- name: 'BUILD_LABEL automation'
devices:
- name: Google Pixel.*

#artifacts:
# download:
# when: always
# match:
# - junit.xml
# - device.log
# directory: ./data/artifacts/

1 change: 0 additions & 1 deletion app/src/main/java/com/mux/player/media3/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package com.mux.player.media3
import android.content.Context
import android.content.Intent
import android.os.Bundle
import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
Expand Down
3 changes: 3 additions & 0 deletions automatedtests/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/build
/buildout
/automated_test_results
81 changes: 81 additions & 0 deletions automatedtests/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
apply plugin: 'com.android.application'


android {
namespace = "com.mux.player.media3"
compileSdkVersion 34

defaultConfig {
applicationId "com.mux.player.media3"
minSdkVersion 21
// Target SDK 31 causes manifest merger errors. One of our dependencies is not setting
// `android:exported` for an Activity. Error logs have no more useful information
targetSdkVersion 33 //project.ext.targetSdkVersion
versionCode 1
versionName "1.0"
multiDexEnabled true
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

buildConfigField("boolean", "SHOULD_REPORT_INSTRUMENTATION_TEST_EVENTS_TO_SERVER", "true")
buildConfigField("String", "INSTRUMENTATION_TEST_ENVIRONMENT_KEY", "\"YOUR_KEY_HERE\"")
}

buildFeatures {
buildConfig true
}

buildTypes {
debug {
minifyEnabled false
}
}


testOptions {
// Changes the directory where Gradle saves test reports. By default, Gradle saves test reports
// in the path_to_your_project/module_name/build/outputs/reports/ directory.
// '$rootDir' sets the path relative to the root directory of the current project.
reportDir "./automated_test_results/reports"
// Changes the directory where Gradle saves test results. By default, Gradle saves test results
// in the path_to_your_project/module_name/build/outputs/test-results/ directory.
// '$rootDir' sets the path relative to the root directory of the current project.
resultsDir "./automated_test_results/results"
}

sourceSets {
androidTest {
// Important, can't get asset file in instrumentation test without this
assets.srcDirs += 'src/main/assets'
}
}

compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
}

dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation 'androidx.appcompat:appcompat:1.4.0'
implementation 'com.google.android.material:material:1.9.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.3'
implementation 'androidx.navigation:navigation-fragment:2.5.3'
implementation 'androidx.navigation:navigation-ui:2.5.3'

androidTestImplementation 'androidx.test:runner:1.5.2'
androidTestImplementation 'androidx.test:rules:1.3.0'
// Optional -- Hamcrest library
androidTestImplementation 'org.hamcrest:hamcrest-library:1.3'
// Optional -- UI testing with Espresso
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
// Optional -- UI testing with UI Automator
androidTestImplementation 'androidx.test.uiautomator:uiautomator:2.2.0'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'

api("com.mux.stats.sdk.muxstats:data-media3:${project.ext.get("muxDataVersion")}")

api 'org.checkerframework:checker-qual:3.33.0'
// Automated tests should always test the local module and not the maven dependency.
implementation project(":library")
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.mux.player.media3;

import com.mux.player.MuxPlayer;

public class MuxStatsHelper {

public static void allowHeaderToBeSentToBackend(MuxPlayer muxStats, String headerName) {
// TODO: implement this
// muxStats.allowHeaderToBeSentToBackend(headerName);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
package com.mux.player.media3.automatedtests;

import static androidx.media3.common.C.TRACK_TYPE_VIDEO;
import static org.junit.Assert.fail;

import androidx.media3.common.Format;
import androidx.media3.common.TrackGroup;
import androidx.media3.exoplayer.source.TrackGroupArray;
import androidx.media3.exoplayer.trackselection.DefaultTrackSelector;
import androidx.media3.exoplayer.trackselection.MappingTrackSelector;
import com.mux.stats.sdk.core.events.playback.RenditionChangeEvent;
import com.mux.stats.sdk.core.model.VideoData;
import java.util.ArrayList;
import org.json.JSONException;
import org.json.JSONObject;
import org.junit.Ignore;
import org.junit.Test;

public class AdaptiveBitStreamTestBase extends TestBase {

@Test
@Ignore("Dummy Test that prevents the 'no runnable methods' failure")
public void dummyTestThatPasses() {
// This test is needed because extending TestBase fools junit into thinking this class has
// @Test-annotated tests instead of just utility code
}

TrackGroupArray getVideoTrackGroupArray() {
DefaultTrackSelector selector = testActivity.getTrackSelector();
MappingTrackSelector.MappedTrackInfo mappedTrackInfo = selector.getCurrentMappedTrackInfo();
for (int rendererTrackIndex = 0; rendererTrackIndex < mappedTrackInfo.getRendererCount();
rendererTrackIndex++) {
int trackType = mappedTrackInfo.getRendererType(rendererTrackIndex);
if (trackType == TRACK_TYPE_VIDEO) {
return mappedTrackInfo
.getTrackGroups(rendererTrackIndex);
}

}
return null;
}

ArrayList<Format> getAvailableVideoRendition() {
ArrayList<Format> result = new ArrayList<>();
TrackGroupArray videoTrackGroupArray = getVideoTrackGroupArray();
for (int trackIndex = 0; trackIndex < videoTrackGroupArray.length; trackIndex++) {
TrackGroup trackGroup = videoTrackGroupArray.get(trackIndex);
for (int formatIndex = 0; formatIndex < trackGroup.length; formatIndex++) {
result.add(trackGroup.getFormat(formatIndex));
}
}
return result;
}

int getSelectedRenditionIndex() throws JSONException {
int renditionChangeIndex = networkRequest.getIndexForFirstEvent(RenditionChangeEvent.TYPE);
if (renditionChangeIndex == -1) {
return -1;
}
JSONObject jo = networkRequest.getEventForIndex(renditionChangeIndex);
if (jo == null || !jo.has(VideoData.VIDEO_SOURCE_WIDTH) || !jo
.has(VideoData.VIDEO_SOURCE_HEIGHT)) {
return -1;
}
int videoWidth = jo.getInt(VideoData.VIDEO_SOURCE_WIDTH);
int videoHeight = jo.getInt(VideoData.VIDEO_SOURCE_HEIGHT);

ArrayList<Format> availableFormats = getAvailableVideoRendition();
int index = 0;
for (Format fmt : availableFormats) {
if (Math.abs(fmt.width - videoWidth) < 10 &&
Math.abs(fmt.height - videoHeight) < 10) {
return index;
}
index++;
}
String availableFormatsStr = "";
for (Format fmt : availableFormats) {
availableFormatsStr += "(" + fmt.width + "x" + fmt.height + ") ";
}
fail("Reported source resolution: " + videoWidth + "x" + videoHeight +
" do not match any of available formats: " + availableFormatsStr);
return -1;
}

void switchRenditionToIndex(int index) {
Format fmt = getAvailableVideoRendition().get(index);
DefaultTrackSelector selector = testActivity.getTrackSelector();
selector.setParameters(selector.buildUponParameters()
.setMaxVideoSize(fmt.width, fmt.height)
.setForceHighestSupportedBitrate(true)
);
}
}
Loading

0 comments on commit d1593fd

Please sign in to comment.