├── README ├── src └── main │ └── java │ ├── module-info.java │ ├── com │ └── phono │ │ └── srtplight │ │ ├── LogFace.java │ │ ├── InvalidRTCPPacketException.java │ │ ├── RTPPacketException.java │ │ ├── RTPDataSink.java │ │ ├── SRTCPSecContext.java │ │ ├── RTPProtocolFace.java │ │ ├── rtcp │ │ ├── REMB.java │ │ └── CCFB.java │ │ ├── BitUtils.java │ │ ├── Log.java │ │ ├── SRTCPProtocolImpl.java │ │ ├── RTPProtocolImpl.java │ │ ├── SRTPProtocolImpl.java │ │ ├── RTCP.java │ │ └── SRTPSecContext.java │ └── biz │ └── source_code │ └── Base64Coder.java ├── .github └── workflows │ ├── maven.yml │ └── maven-publish.yml ├── README.md └── pom.xml /README: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/main/java/module-info.java: -------------------------------------------------------------------------------- 1 | module com.phono.srtplight { 2 | exports com.phono.srtplight; 3 | exports biz.source_code; 4 | exports com.phono.srtplight.rtcp; 5 | } 6 | -------------------------------------------------------------------------------- /src/main/java/com/phono/srtplight/LogFace.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this template, choose Tools | Templates 3 | * and open the template in the editor. 4 | */ 5 | 6 | package com.phono.srtplight; 7 | 8 | /** 9 | * 10 | * @author tim 11 | */ 12 | public interface LogFace { 13 | 14 | void e(String message) ; 15 | 16 | void d(String message) ; 17 | 18 | void w(String message) ; 19 | 20 | void v(String message) ; 21 | 22 | void i(String message) ; 23 | 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/com/phono/srtplight/InvalidRTCPPacketException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package com.phono.srtplight; 7 | 8 | /** 9 | * 10 | * @author thp 11 | */ 12 | public class InvalidRTCPPacketException extends Exception { 13 | 14 | public InvalidRTCPPacketException(String message) { 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/com/phono/srtplight/RTPPacketException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package com.phono.srtplight; 7 | 8 | import java.io.IOException; 9 | 10 | /** 11 | * 12 | * @author thp 13 | */ 14 | public class RTPPacketException extends IOException { 15 | 16 | public RTPPacketException(String mess) { 17 | super(mess); 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /.github/workflows/maven.yml: -------------------------------------------------------------------------------- 1 | # This workflow will build a Java project with Maven 2 | # For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven 3 | 4 | name: Java CI with Maven 5 | 6 | on: 7 | push: 8 | branches: [ main ] 9 | pull_request: 10 | branches: [ main ] 11 | 12 | jobs: 13 | build: 14 | 15 | runs-on: ubuntu-latest 16 | 17 | steps: 18 | - uses: actions/checkout@v2 19 | - name: Set up JDK 11 20 | uses: actions/setup-java@v1 21 | with: 22 | java-version: 11 23 | - name: Build with Maven 24 | run: mvn -B package --file pom.xml 25 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # srtplight 2 | ## set of classes implementing a simple (S)RTP stack 3 | - In pure Java. 4 | - Acceptably quick as the JVM offloads AES to hardware when possible (eg on ARM) 5 | - Supports RTP, SRTP and (S)RTCP 6 | - SRTP in AES_CM_128_HMAC_SHA1_80 only 7 | - Tested against all the major browser webRTC implementations 8 | - Does _not_ include WebRTC's DTLS-SRTP key exchange (look at BouncyCastle for that) 9 | ## It was originally written for Voxeo's Phono project as part of an applet based in-browser phone. 10 | - issues,PRs,fixes etc are welcome 11 | - Apache license. 12 | - now used in |pipe| (see github.com/pipe/) 13 | 14 | ## See also a minimal webRTC implemenation 15 | https://github.com/pipe/whipi 16 | based on this library, BouncyCastle and 17 | https://github.com/steely-glint/slice 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /src/main/java/com/phono/srtplight/RTPDataSink.java: -------------------------------------------------------------------------------- 1 | package com.phono.srtplight; 2 | 3 | /* 4 | * Copyright 2011 Voxeo Corp. 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | * 18 | */ 19 | 20 | 21 | 22 | public interface RTPDataSink { 23 | public void dataPacketReceived(byte [] data, long stamp, long index); 24 | } 25 | -------------------------------------------------------------------------------- /.github/workflows/maven-publish.yml: -------------------------------------------------------------------------------- 1 | # This workflow will build a package using Maven and then publish it to GitHub packages when a release is created 2 | # For more information see: https://github.com/actions/setup-java#apache-maven-with-a-settings-path 3 | 4 | name: Maven Package 5 | 6 | on: 7 | release: 8 | types: [created] 9 | 10 | jobs: 11 | build: 12 | 13 | runs-on: ubuntu-latest 14 | 15 | steps: 16 | - uses: actions/checkout@v2 17 | - name: Set up JDK 11 18 | uses: actions/setup-java@v1 19 | with: 20 | java-version: 11 21 | server-id: github # Value of the distributionManagement/repository/id field of the pom.xml 22 | settings-path: ${{ github.workspace }} # location for the settings.xml file 23 | 24 | - name: Build with Maven 25 | run: mvn -B package --file pom.xml 26 | 27 | - name: Publish to GitHub Packages Apache Maven 28 | run: mvn deploy -s $GITHUB_WORKSPACE/settings.xml 29 | env: 30 | GITHUB_TOKEN: ${{ github.token }} 31 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | com.phono 5 | srtplight 6 | 1.1.12 7 | jar 8 | 9 | 10 | 11 | org.apache.maven.plugins 12 | maven-compiler-plugin 13 | 3.6.1 14 | 15 | 16 | 17 | 18 | UTF-8 19 | 11 20 | 11 21 | 22 | 23 | 24 | github 25 | GitHub Packages 26 | https://maven.pkg.github.com/steely-glint/srtplight 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /src/main/java/com/phono/srtplight/SRTCPSecContext.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package com.phono.srtplight; 7 | 8 | import java.security.GeneralSecurityException; 9 | 10 | /** 11 | * 12 | * @author tim 13 | */ 14 | class SRTCPSecContext extends SRTPSecContext { 15 | 16 | public SRTCPSecContext(boolean b) { 17 | } 18 | 19 | /* 20 | 4.3.2. SRTCP Key Derivation 21 | 22 | SRTCP SHALL by default use the same master key (and master salt) as 23 | SRTP. To do this securely, the following changes SHALL be done to 24 | the definitions in Section 4.3.1 when applying session key derivation 25 | for SRTCP. 26 | 27 | Replace the SRTP index by the 32-bit quantity: 0 || SRTCP index 28 | (i.e., excluding the E-bit, replacing it with a fixed 0-bit), and use 29 |