shogo4405 / haishinkit.kt Goto Github PK
View Code? Open in Web Editor NEWCamera and Microphone streaming library via RTMP for Android.
License: BSD 3-Clause "New" or "Revised" License
Camera and Microphone streaming library via RTMP for Android.
License: BSD 3-Clause "New" or "Revised" License
I have 2 applications one is the pubblish and the other is just the client. When I connect to stream in client i recive this:
FATAL EXCEPTION: com.haishinkit.codec.AudioCodec
Process: com.audioguiame.guidum, PID: 19985
java.lang.IllegalArgumentException: Invalid audio buffer size.
at android.media.AudioTrack.audioBuffSizeCheck(AudioTrack.java:1209)
at android.media.AudioTrack.(AudioTrack.java:615)
at android.media.AudioTrack.(AudioTrack.java:562)
at android.media.AudioTrack.(AudioTrack.java:516)
at android.media.AudioTrack.(AudioTrack.java:457)
at com.haishinkit.net.NetStream.createAudioTrack$haishinkit_release(NetStream.kt:152)
at com.haishinkit.rtmp.RtmpMuxer.onFormatChanged(RtmpMuxer.kt:262)
at com.haishinkit.codec.Codec.setOutputFormat(Codec.kt:170)
at com.haishinkit.codec.Codec.access$setOutputFormat(Codec.kt:18)
at com.haishinkit.codec.Codec$Callback.onOutputFormatChanged(Codec.kt:92)
at android.media.MediaCodec$EventHandler.handleCallback(MediaCodec.java:1712)
at android.media.MediaCodec$EventHandler.handleMessage(MediaCodec.java:1646)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:193)
at android.os.HandlerThread.run(HandlerThread.java:65)
We have this application in ios and is working well "pubblish" (ios, android) to ios client but with android receiving that.
FATAL EXCEPTION: com.haishinkit.codec.AudioCodec
Process: com.audioguiame.guidum, PID: 19985
java.lang.IllegalArgumentException: Invalid audio buffer size.
at android.media.AudioTrack.audioBuffSizeCheck(AudioTrack.java:1209)
at android.media.AudioTrack.(AudioTrack.java:615)
at android.media.AudioTrack.(AudioTrack.java:562)
at android.media.AudioTrack.(AudioTrack.java:516)
at android.media.AudioTrack.(AudioTrack.java:457)
at com.haishinkit.net.NetStream.createAudioTrack$haishinkit_release(NetStream.kt:152)
at com.haishinkit.rtmp.RtmpMuxer.onFormatChanged(RtmpMuxer.kt:262)
at com.haishinkit.codec.Codec.setOutputFormat(Codec.kt:170)
at com.haishinkit.codec.Codec.access$setOutputFormat(Codec.kt:18)
at com.haishinkit.codec.Codec$Callback.onOutputFormatChanged(Codec.kt:92)
at android.media.MediaCodec$EventHandler.handleCallback(MediaCodec.java:1712)
at android.media.MediaCodec$EventHandler.handleMessage(MediaCodec.java:1646)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:193)
at android.os.HandlerThread.run(HandlerThread.java:65)
0.11.1
No response
No response
No response
No response
Hello, recently I've discovered that sometimes the opaque parametre contains a space in it's value that will generate a malformed URL.
For this I've used the https://github.com/shogo4405/HaishinKit.dart available for Flutter, but from what I've seen the issue is only reproducing on Android side with the error at the end, that's why this bug is submited directly to the Android project.
W/NetSocketImpl(30031): java.lang.IllegalArgumentException: Illegal character in query at index 122: rtmp://user:passwd@site:1935/mount/?authmod=adobe&user=user&opaque=Qul nQ==&challenge=080f28b6&response=sAUdK5ZAnzX1KKxadxK6zQ==
W/NetSocketImpl(30031): at java.net.URI.create(URI.java:848)
W/NetSocketImpl(30031): at com.haishinkit.rtmp.RtmpConnection.connect(RtmpConnection.kt:220)
W/NetSocketImpl(30031): at com.haishinkit.rtmp.RtmpAuthenticator.handleEvent(RtmpAuthenticator.kt:47)
W/NetSocketImpl(30031): at com.haishinkit.event.EventDispatcher.dispatchEvent(EventDispatcher.kt:37)
W/NetSocketImpl(30031): at com.haishinkit.event.EventDispatcher.dispatchEventWith(EventDispatcher.kt:60)
W/NetSocketImpl(30031): at com.haishinkit.rtmp.message.RtmpCommandMessage.execute(RtmpCommandMessage.kt:81)
W/NetSocketImpl(30031): at com.haishinkit.rtmp.RtmpConnection.listen$haishinkit_release(RtmpConnection.kt:308)
W/NetSocketImpl(30031): at com.haishinkit.rtmp.RtmpSocket.onInput(RtmpSocket.kt:126)
W/NetSocketImpl(30031): at com.haishinkit.net.NetSocketImpl.doInput(NetSocketImpl.kt:107)
W/NetSocketImpl(30031): at com.haishinkit.net.NetSocketImpl.doConnection(NetSocketImpl.kt:167)
W/NetSocketImpl(30031): at com.haishinkit.net.NetSocketImpl.access$doConnection(NetSocketImpl.kt:21)
W/NetSocketImpl(30031): at com.haishinkit.net.NetSocketImpl$connect$1.invokeSuspend(NetSocketImpl.kt:60)
W/NetSocketImpl(30031): at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
W/NetSocketImpl(30031): at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
W/NetSocketImpl(30031): at kotlinx.coroutines.internal.LimitedDispatcher$Worker.run(LimitedDispatcher.kt:115)
W/NetSocketImpl(30031): at kotlinx.coroutines.scheduling.TaskImpl.run(Tasks.kt:100)
W/NetSocketImpl(30031): at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:584)
W/NetSocketImpl(30031): at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:793)
W/NetSocketImpl(30031): at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:697)
W/NetSocketImpl(30031): at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:684)
W/NetSocketImpl(30031): Caused by: java.net.URISyntaxException: Illegal character in query at index 122: rtmp://user:passwd@site:1935/mount/?authmod=adobe&user=user&opaque=Qul nQ==&challenge=080f28b6&response=sAUdK5ZAnzX1KKxadxK6zQ==
W/NetSocketImpl(30031): at java.net.URI$Parser.fail(URI.java:2893)
W/NetSocketImpl(30031): at java.net.URI$Parser.checkChars(URI.java:3066)
W/NetSocketImpl(30031): at java.net.URI$Parser.parseHierarchical(URI.java:3156)
W/NetSocketImpl(30031): at java.net.URI$Parser.parse(URI.java:3098)
W/NetSocketImpl(30031): at java.net.URI.<init>(URI.java:584)
W/NetSocketImpl(30031): at java.net.URI.create(URI.java:846)
W/NetSocketImpl(30031): ... 19 more
Latest version available on https://github.com/shogo4405/HaishinKit.dart
No response
No response
No response
No response
Is your feature request related to a problem? Please describe.
The current minSdk
setting for the vulkan module is 26, but it's 21 for the main haishinkit
module.
Is it possible to use only the haishinkit
module so that it can be used in an app that wishes to keep compatibility with API 21?
Would adding just the haishinkit
module as a dependency work?
Describe the solution you'd like
Ability to use HaishinKit on API 21
Describe alternatives you've considered
Since I anyway have a fork to enable building with jitpack, I could revert the commit that uses features only available in API 26.
Describe the bug
Followup from #48, It works fine when not setting any resolution (so letting it use the default of 640x360), but when I add cameraSource.resolution = Size(480, 640)
in the onResume()
method of the example app's CameraTabFragment, both the view on the phone and the stream are stretched.
To Reproduce
Steps to reproduce the behavior:
cameraSource.resolution = Size(480, 640)
in the onResume()
method of the example app's CameraTabFragmentExpected behavior
Video should not be stretched
Screenshots
Phone | VLC |
---|---|
Desktop (please complete the following information):
Smartphone (please complete the following information):
Hi, Iv'e tested the example app with 3 devices:
Samsung J7, Android version 8.1.0:
As soon as I click the "publish" button:
Screen freeze but the audio still working and broadcasting
Samsung 9+ , Android version 10:
As soon as I click the "publish" button:
Working but crashing after few minutes for unknown reason
Xiaomi Mi A2 , Android version 10:
As soon as I click the "publish" button:
crash with this exception:
CAMERA_ERROR (3): submitRequestList - cannot use a surface that wasn't configured
Can you provide a workaround for this issue please?
Describe the bug
Gradle can't use packages with dots in the name, so the library must be referred to as HaishinKit~kt
. On the JitPack page for the correctly named package, the 0.9.4
build failed. However, specifying the commit of the 0.9.4
tag in JitPack builds fine, so can you please delete the artifact so it can be rebuilt?
To Reproduce
Steps to reproduce the behavior:
implementation 'com.github.shogo4405.HaishinKit~kt:haishinkit:0.9.4'
to a build.gradle
Expected behavior
Project can sync and build
JitPack build log
https://jitpack.io/com/github/shogo4405/HaishinKit~kt/0.9.4/build.log
Build log of 0.9.4
commit
https://jitpack.io/com/github/shogo4405/HaishinKit~kt/5bab74f/build.log
Is your feature request related to a problem? Please describe.
I want to forward a video Stream to a VMS server, the video is captured by a different source and streamed to my phone via an HTTP connection, I want to forward it to a VMS Server
Right now I can see a method appendBuffer() available in swift, but it is not available in haishinkit.kt
Describe the solution you'd like
Can I use the haishinkits RTMP stream class to append a video buffer to stream to a VMS server, as well as append an audio buffer?
Describe alternatives you've considered
I have looked into the module but unable to find a method to stream out a buffer
Additional context
N/A
android.hardware.camera2.CameraAccessException: CAMERA_ERROR (3): createDefaultRequest:1290: Camera 0: Error creating default request for template 1: Function not implemented (-38)
run demo on the phone
Could not compile shader 35633
0.13.6
oppo pfvm10 (oppo A56 5G),android 12
No response
No response
Camera 3 is not available. Ignore physical camera status change
android.hardware.camera2.CameraAccessException: CAMERA_ERROR (3): createDefaultRequest:1290: Camera 0: Error creating default request for template 1: Function not implemented (-38)
Caused by: android.os.ServiceSpecificException: createDefaultRequest:1290: Camera 0: Error creating default request for template 1: Function not implemented (-38) (code 10)
Describe the bug
Expected behavior
CloudWatch logs should not show any error. RTMP stream should go to YouTube. Stream should be visible in YouTube.
Smartphone (please complete the following information):
Additional context
Posted this question on aws-forum for the same. Below is there response:
Please help me to fix this issue. iOS variant of your library works with same Elemental MediaLive setup.
Hi friend,
We are using this lib swift version and it is good.
Now, we are working for Android, and I would to now when you can release this lib for Android version.
Please let me know about it!
Thanks friend!
com.magicpolygon.storycircles.debug W java.nio.BufferOverflowException
at java.nio.Buffer.nextPutIndex(Buffer.java:542)
at java.nio.HeapByteBuffer.putDouble(HeapByteBuffer.java:539)
at com.haishinkit.amf.Amf0Serializer.putDouble(Amf0Serializer.kt:17)
at com.haishinkit.amf.Amf0Serializer.putObject(Amf0Serializer.kt:89)
at com.haishinkit.amf.Amf0Serializer.putMap(Amf0Serializer.kt:39)
at com.haishinkit.rtmp.message.RtmpCommandMessage.encode(RtmpCommandMessage.kt:28)
at com.haishinkit.rtmp.RtmpChunk.encode(RtmpChunk.kt:15)
at com.haishinkit.rtmp.RtmpConnection.doOutput$haishinkit_release(RtmpConnection.kt:263)
at com.haishinkit.rtmp.RtmpSocket.onInput(RtmpSocket.kt:121)
at com.haishinkit.net.NetSocketImpl.doInput(NetSocketImpl.kt:107)
at com.haishinkit.net.NetSocketImpl.doConnection(NetSocketImpl.kt:167)
at com.haishinkit.net.NetSocketImpl.access$doConnection(NetSocketImpl.kt:21)
at com.haishinkit.net.NetSocketImpl$connect$1.invokeSuspend(NetSocketImpl.kt:60)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
at kotlinx.coroutines.internal.LimitedDispatcher.run(LimitedDispatcher.kt:42)
at kotlinx.coroutines.scheduling.TaskImpl.run(Tasks.kt:95)
at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:570)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:750)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:677)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:664)
When user multipal time start and stop live telecast.
When user multipal time start and stop live telecast.
0.11.0
No response
No response
No response
No response
Describe the bug
The test application always fails at start time on my phones.
Adding some GlUtil.checkGlError
, I find out that it's the call to GLES10.glOrthof
line 133 of GlKernel.kt on last main
branch that failed with error 0x502
Skipping this line, the application is launching (the camera preview do not take all the phone screen and the image is not as clean as expected, but that's probably fair)
To Reproduce
Steps to reproduce the behavior:
Expected behavior
The application is not crashing
Smartphone:
Hello.
Trying to use HaishinKit to stream to Amazon Interactive Video Service.
I'm able to connect to IVS and don't get any error, but the IVS console never shows the stream.
Has HaishinKit been used with IVS? Any suggestion or insight how to debug the connection?
Help will be appreciated.
Using HaishinKit to stream, when viewing the stream the audio and video appear to not be synced. From what I've observed the audio seems to be delayed anywhere from about 100ms to 1 second.
This happens on all devices I've tested, from both the example project in this repository, as well as my own app with using this library.
The audio should be in sync with the video.
0.11.0
Device: Google Pixel 2XL
OS: Android 11
Device: Samsung Galaxy Tab A7 Lite
OS: Android 13
Device: Samsung Galaxy S20 FE
OS: Android 11
No response
No response
No response
I just wondering if you planning to release thes feature soon, if it is in process
While switching from the front camera to the back camera or vice versa, the current camera preview is changed to 180 degrees, and switching camera (version 0.10.3)
cameraSource.switchCamera()
It should change the front camera to the back camera and vice versa.
0.10.3
No response
No response
No response
No response
We are getting encoder related debug log while doing Http live streaming for audio using RTMP in the latest version 0.13.6. We are not doing video streaming inside our app.
Previously we are using 0.11.2 version and in that audio live streaming was working fine.
Here is the log : ```
{code=NetConnection.Connect.Success, clientid=1.628338297E9, data=Amf0EcmaArray{{version=3,5,7,7009}}, level=status, description=Connection succeeded., objectEncoding=0.0}
NetConnection.Connect.Success
NetStream.Publish.Start
NetConnection.Connect.Success
Hn RTMP Broadcast started 1
current=INITIALIZED, change=OPEN
current=OPEN, change=PUBLISH
{code=NetStream.Publish.Denied, clientid=1.628338297E9, level=error, description=RTMP Publishing not allowed. Client is not in list of valid encoders.}
NetStream.Publish.Denied
NetStream.Publish.Start
NetConnection.Connect.Success
{code=NetConnection.Connect.Closed, level=status}
NetConnection.Connect.Closed
NetStream.Publish.Start
NetConnection.Connect.Success
### To Reproduce
While doing Http live streaming for audio using RTMP in the latest version 0.13.6
### Expected behavior
It should be work same as older version 0.11.2
### Version
0.13.6
### Smartphone info.
One plus nord 2 - 5G
Android operating system - 13
(Not working for all the other devices and different OS version)
### Additional context
Due to encoder related changes in the latest version it stopped working. How can I overcome this issue?
### Screenshots
_No response_
### Relevant log output
```shell
{code=NetConnection.Connect.Success, clientid=1.628338297E9, data=Amf0EcmaArray{{version=3,5,7,7009}}, level=status, description=Connection succeeded., objectEncoding=0.0}
NetConnection.Connect.Success
NetStream.Publish.Start
NetConnection.Connect.Success
Hn RTMP Broadcast started 1
current=INITIALIZED, change=OPEN
current=OPEN, change=PUBLISH
{code=NetStream.Publish.Denied, clientid=1.628338297E9, level=error, description=RTMP Publishing not allowed. Client is not in list of valid encoders.}
NetStream.Publish.Denied
NetStream.Publish.Start
NetConnection.Connect.Success
{code=NetConnection.Connect.Closed, level=status}
NetConnection.Connect.Closed
NetStream.Publish.Start
NetConnection.Connect.Success
Describe the bug
Adding event listener into RtmpConnection object is returning only one status event - code=NetConnection.Connect.Success
. It's not possible to get other statuses like REJECTED, CLOSED, FAILED.
To Reproduce
Steps to reproduce the behavior:
val connection = RtmpConnection()
connection.addEventListener(Event.RTMP_STATUS, this)
connection.connect("rtmpStreamUrl")
Expected behavior
Get other statuses than SUCCESS, like CLOSED, FAILED.
Smartphone (please complete the following information):
Additional context
I've also tried adding listener with IO_ERROR, but this is not returning any error/message/status.
Hi.
Does this library work with any RTMP server?
Like this -> Rtmp node js
or like this -> Node media server
Here is the link for the audio live streaming issue which is already closed. After your comment in that issue, I have made changes accordingly but audio playback stopped working at receiver end.
We have implemented the changes based on your comments. However, following this update, we are encountering an audio playback issue on the receiver's end during live audio streaming. I do not see any obvious errors on the streaming side.Attached the logs for the streaming side as well for your review here, the receiver is experiencing a SocketTimeoutException while listening.
Is there any other change made in the latest version apart from the encoder? Is there any change related to the streaming side?
Any suggestions to fix this issue? Please let me know.
We have checked again with the older version v0.11.2, in which audio streaming and playback was working fine.
Scenario: I am starting live audio streaming from android device and playback it from another device, but the playback stalls every time, resulting in a SocketTimeoutException. We have also tried playback with iPhone/iPad, and it was not working on those devices either.
Here I am attaching log for streaming end and playback end.
live audio playback log.txt
live streaming log.txt
Scenario: I am starting live audio streaming from android device and playback it from another device, but the playback stalls every time, resulting in a SocketTimeoutException. We have also tried playback with iPhone/iPad, and it was not working on those devices either.
Audio playback should be work fine at the receiver end.
0.13.6
No response
No response
No response
No response
For example, If I try to upload/publish a video/audio stream and in between network is lost will this client cache the stream, and when the network is connected it will start the stream upload from where it got disconnected. If not can you share some links on how to achieve this?
Hi, I've observed that the videoSetting.frameRate method's configuration is not effective in main branch. Additionally, the default frameRate you have set is 30, but the actual frameRate outputted in your FrameTracker is 60.
1.Open the sample app.
2.Set videoSetting.frameRate to 30.
3.Monitor the frameRate of the video status in the FrameTracker logs in Logcat.
1.Open the sample app.
2.Set videoSetting.frameRate to 30.
3.Monitor the frameRate of the video status in the FrameTracker logs in Logcat.
Expected frameRate is 30.
latest main branch
No response
No response
No response
No audio in the stream after calling connection.close()
and then connection.connect(RTMP_URL)
. Works after restarting Activity (init-ing connection again).
RtmpConnection
and RtmpStream
with camera and audio source.connection.close()
.connection.connect(RTMP_URL)
(RTMP_URL
is a valid rtmp://
URL, audio works on the first connection, but not this second one).Audio should continue
0.10.4
Android 12 (One UI 4.1)
Using nginx RTMP module as backend (and manually viewing recorded files on the server).
No response
No response
Describe the bug
HkSurfaceView利用時、RtmpConnection.close()を呼んだタイミングで
次の例外が繰り返し発生しクラッシュしてしまいました。
2022-03-11 09:03:56.606 6720-6720/com.haishinkit.studio E/AndroidRuntime: at com.haishinkit.view.HkSurfaceView.stopRunning(HkSurfaceView.kt:86)
at com.haishinkit.media.Camera2Source.stopRunning(Camera2Source.kt:176)
at com.haishinkit.view.HkSurfaceView.stopRunning(HkSurfaceView.kt:86)
at com.haishinkit.media.Camera2Source.stopRunning(Camera2Source.kt:176)
at com.haishinkit.view.HkSurfaceView.stopRunning(HkSurfaceView.kt:86)
...以下 StackOverflowが発生するまで繰り返し
To Reproduce
Smartphone
Describe the bug
When streaming using HaishinStudio, the stream has a resolution of 640x360, but the resolution in Camera2Source is 640x480. I looked at the code, and it seems like the resolution
variable is never set in Camera2Source
, so the stream resolution isn't set either. Even if I manually set the stream resolution to be equal to the source resolution, the video still has the wrong aspect ratio.
I'm testing this with commit 513e551, since the next commit seems to have broken video streaming (only the audio is available in VLC).
To Reproduce
Steps to reproduce the behavior:
Expected behavior
The video has the correct aspect ratio.
I don't actually understand how/where the "correct" aspect ratio comes from, the variable setting seems a bit circular to me.
Screenshots
(The object in frame is a cube)
On Phone | In VLC |
---|---|
Desktop (please complete the following information):
Smartphone (please complete the following information):
The jitpack artifact location is listed as
com.github.shogo4405:HaishinKit~kt:(...)
with a colon (":") separating the group from the module. This should be:
com.github.shogo4405.HaishinKit~kt:(...)
-- with a period (".") separating the artifcat group from the module.
In current README:
dependencies {
implementation 'com.github.shogo4405:HaishinKit~kt:haishinkit:x.x.x'
implementation 'com.github.shogo4405:HaishinKit~kt:vulkan:x.x.x'
}
In an Android project, attempt to import the HaishinKit dependency using the location provided:
dependencies {
implementation 'com.github.shogo4405:HaishinKit~kt:haishinkit:0.11.0'
}
Result: package can't be resolved.
With a period separating the artifact group from the module, the package resolves:
dependencies {
implementation 'com.github.shogo4405.HaishinKit~kt:haishinkit:0.11.0'
}
N/A
No response
No response
No response
No response
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.