Skip to content

Commit ae754a8

Browse files
committed
on media format events
1 parent 75149fd commit ae754a8

8 files changed

Lines changed: 52 additions & 32 deletions

File tree

.github/workflows/build.yaml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: build
2+
3+
on: [push]
4+
5+
jobs:
6+
build:
7+
name: build
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v3
11+
- name: Set up JDK 11
12+
uses: actions/setup-java@v3
13+
with:
14+
java-version: 11
15+
distribution: adopt
16+
- name: Build with Gradle
17+
uses: gradle/gradle-build-action@v2
18+
with:
19+
gradle-version: 7.4.2
20+
arguments: build

.gitignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
.gradle
22
gradlew
33
gradlew.bat
4-
gradle/wrapper/*
5-
!gradle/wrapper/gradle-wrapper.properties
4+
gradle
65
.idea
76
out
87
build

.travis.yml

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

build.gradle

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,48 @@
11
plugins {
2-
id 'maven'
32
id 'java-library'
43
}
54

65
group 'com.github.serezhka'
7-
version '1.0.4'
6+
version '1.0.5'
87

98
sourceCompatibility = JavaVersion.VERSION_11
109
targetCompatibility = JavaVersion.VERSION_11
1110

1211
repositories {
13-
jcenter()
1412
mavenCentral()
1513
maven {
1614
url "https://jitpack.io"
1715
}
1816
}
1917

2018
dependencies {
21-
implementation "io.netty:netty-all:4.1.52.Final"
22-
implementation "org.slf4j:slf4j-api:1.7.30"
23-
implementation "com.github.serezhka:java-airplay-lib:1.0.4"
24-
// implementation files('C:\\projects\\java-airplay-lib\\build\\libs\\java-airplay-lib-1.0.4-all.jar')
19+
implementation 'io.netty:netty-all:4.1.77.Final'
20+
implementation 'org.slf4j:slf4j-api:1.7.36'
21+
implementation 'com.github.serezhka:java-airplay-lib:1.0.5'
22+
// implementation files("$project.rootDir\\..\\java-airplay-lib\\build\\libs\\java-airplay-lib-1.0.5-all.jar")
2523

26-
testImplementation "org.junit.jupiter:junit-jupiter-api:5.4.2"
27-
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:5.4.2"
24+
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.2'
25+
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.2'
2826
}
2927

3028
test {
3129
useJUnitPlatform()
3230
}
3331

3432
wrapper {
35-
gradleVersion = '6.1.1'
33+
gradleVersion = '7.4.2'
3634
distributionType = Wrapper.DistributionType.ALL
3735
}
3836

3937
task fatJar(type: Jar) {
40-
classifier = 'all'
38+
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
39+
archiveClassifier.set('all')
4140
from { configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) } }
4241
with jar
4342
}
4443

4544
task jarSources(type: Jar) {
46-
classifier = 'sources'
45+
archiveClassifier.set('sources')
4746
from sourceSets.main.allSource
4847
}
4948

gradle/wrapper/gradle-wrapper.properties

Lines changed: 0 additions & 5 deletions
This file was deleted.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
11
package com.github.serezhka.jap2server;
22

3+
import com.github.serezhka.jap2lib.rtsp.AudioStreamInfo;
4+
import com.github.serezhka.jap2lib.rtsp.VideoStreamInfo;
5+
36
public interface AirplayDataConsumer {
47

58
void onVideo(byte[] video);
69

10+
void onVideoFormat(VideoStreamInfo videoStreamInfo);
11+
712
void onAudio(byte[] audio);
13+
14+
void onAudioFormat(AudioStreamInfo audioInfo);
815
}

src/main/java/com/github/serezhka/jap2server/internal/handler/audio/AudioHandler.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ protected void channelRead0(ChannelHandlerContext ctx, DatagramPacket msg) throw
5454
return;
5555
}
5656

57-
log.debug("Got audio packet. flag: {}, type: {}, prevSeqNum: {}, curSecNum: {}, audio packets in buffer: {}",
58-
flag, type, prevSeqNum, curSeqNo, packetsInBuffer);
57+
/*log.debug("Got audio packet. flag: {}, type: {}, prevSeqNum: {}, curSecNum: {}, audio packets in buffer: {}",
58+
flag, type, prevSeqNum, curSeqNo, packetsInBuffer);*/
5959

6060
AudioPacket audioPacket = buffer[curSeqNo % buffer.length];
6161
audioPacket

src/main/java/com/github/serezhka/jap2server/internal/handler/control/RTSPHandler.java

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import com.github.serezhka.jap2lib.rtsp.AudioStreamInfo;
44
import com.github.serezhka.jap2lib.rtsp.MediaStreamInfo;
5+
import com.github.serezhka.jap2lib.rtsp.VideoStreamInfo;
56
import com.github.serezhka.jap2server.AirplayDataConsumer;
67
import com.github.serezhka.jap2server.internal.AudioControlServer;
78
import com.github.serezhka.jap2server.internal.AudioReceiver;
@@ -52,9 +53,11 @@ protected boolean handleRequest(ChannelHandlerContext ctx, Session session, Full
5253
case AUDIO:
5354
AudioStreamInfo audioStreamInfo = (AudioStreamInfo) mediaStreamInfo;
5455

55-
if (!audioStreamInfo.getAudioFormat().equals(AudioStreamInfo.AudioFormat.AAC_ELD_44100_2)) {
56-
log.error("Audio format {} is not supported yet!", audioStreamInfo.getAudioFormat());
57-
}
56+
log.info("Audio format is: {}", audioStreamInfo.getAudioFormat());
57+
log.info("Audio compression type is: {}", audioStreamInfo.getCompressionType());
58+
log.info("Audio samples per frame is: {}", audioStreamInfo.getSamplesPerFrame());
59+
60+
airplayDataConsumer.onAudioFormat(audioStreamInfo);
5861

5962
var audioHandler = new AudioHandler(session.getAirPlay(), airplayDataConsumer);
6063
var audioReceiver = new AudioReceiver(audioHandler, this);
@@ -75,9 +78,14 @@ protected boolean handleRequest(ChannelHandlerContext ctx, Session session, Full
7578

7679
session.getAirPlay().rtspSetupAudio(new ByteBufOutputStream(response.content()),
7780
audioReceiver.getPort(), audioControlServer.getPort());
81+
7882
break;
7983

8084
case VIDEO:
85+
VideoStreamInfo videoStreamInfo = (VideoStreamInfo) mediaStreamInfo;
86+
87+
airplayDataConsumer.onVideoFormat(videoStreamInfo);
88+
8189
var mirroringHandler = new MirroringHandler(session.getAirPlay(), airplayDataConsumer);
8290
var airPlayReceiver = new MirroringReceiver(airPlayPort, mirroringHandler);
8391
var airPlayReceiverThread = new Thread(airPlayReceiver);

0 commit comments

Comments
 (0)