Regarding sending a file to Websocket via android application - android

I want to upload a mp3 file via Websocket in Android Application.
I was using the external library
http://autobahn.ws/android/
But the problem is that through this library,I cannot upload a big file.say 5 Mb.
I tried researching on similar types of libraries.But could not found a suitable one.
Has anyone tried to upload file on WebSocket in Android Application.
Thanks

As per the mentioned error you are receiving "WebSocketException: frame payload too large", if you go to the source code of the library you are using and search for error you will find out the limitation imposed by the library itself.
// immediately bail out on frame too large
if (payload_len > mOptions.getMaxFramePayloadSize()) {
throw new WebSocketException("frame payload too large");
}
You'll find the this limitation in WebSocketOptions.java
mMaxFramePayloadSize = 128 * 1024;

Related

What are the standard ways of reading and writing audio files on Android / Kotlin?

What are the standard ways of reading and writing audio files on Android / Kotlin?
I am very confused. I've found plenty of posts that discuss this at some level, but they're all either giving a third party answer (someone's own implementation like https://medium.com/#rizveeredwan/working-with-wav-files-in-android-52e9500297e or https://stackoverflow.com/a/43569709/4959635 or https://gist.github.com/kmark/d8b1b01fb0d2febf5770) or using some Java class, of which I don't know how it's related to the Android SDK (https://stackoverflow.com/a/26598862/4959635, https://gist.github.com/niusounds/3e49013a8e942cdba3fbfe1c336b61fc, https://github.com/google/oboe/issues/548#issuecomment-502758633).
I cannot find a standard way from the Android documentation. Some answer said to use https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.io/java.io.-input-stream/read-bytes.html for reading, but I'm quite sure this doesn't parse the file header.
So what's the standard way of processing audio files on Android / Kotlin?
I'm already using dr_wav just fine on desktop, so I am actually thinking of just using that through NDK and maybe creating a wrapper to it.
Your use case is not clear from the question.
Assuming that you need to process raw audio data (PCM samples) - the standard way is to read the (compressed) input file using the MediaExtractor and decode the packets using the MediaCodec. Note that the documentation includes some example code.
The MediaCodec outputs ByteBuffers containing raw PCM samples. The binary format is described here.
Well, there is no strict standard.
In production, you usually choose stable third party library or your company's reusable internal solution for this kind of tasks. You still can implement it yourself, but it will cost you time, since most likely the implementation will consist of hundreds of lines of code and you probably will just create another variation of existing solution which is present on the internet.

how i can implement live streaming in android

I want to create a live stream functionality in my android app. I got an example from this link:
https://github.com/youtube/yt-watchme.
While running this code i got an error, "libffmpeg" can't load. To solve this issue i downloaded pre-built 'libffmpeg' and added to my project. After that I getting the issue:
java.lang.UnsatisfiedLinkError: dlopen failed: file offset
for the library "/data/app/com.google.android.apps.watchme-2/
lib/arm/libffmpeg.so" >= file size: 0 >= 0.
How I can solve this issue.
Have you checked on this documentation? The YouTube Live Streaming API lets you create, update, and manage live events on YouTube. Using the API, you can schedule events (broadcasts) and associate them with video streams, which represent the actual broadcast content.
For your error: dlopen failed: file offset for the library, you may check on this related SO thread. Make sure that you have downloaded and copied the files properly.
You can also check on this Java Code Samples that used the Google APIs Client Library for Java which are available for the YouTube Live Streaming API.

cordova-plugin-media: Parse ".amr" Audio File on nodejs server

I'm using the cordova-plugin-media plugin to record audio-files from android and ios devices.
However, android only allows to record the file in ".amr" ending, iOS on the otherside only supports ".wav".
Playing the ".wav" from the iOS device on Android works, however, iOS doesn't support ".amr" files. That's why I have to convert them somehow.
Since I couldn't find any cordova-plugin converting the ".amr" file on the clientside besides this one (which is based on an external API and extreeeemly slow + not fully working - in addition that I'm not a fan of doing file-conversions on the client-side), I'm looking for a solution on the server-side:
Is there any javascript-library (best if it's "nodejs-friendly") allowing me to easily convert an ".amr" file to a ".wav" or ".mp3" (or similiar - just playable on iOS)?
Despite ffmpeg (which I couldn't manage to install properly), I couldn't find ANY solutions... :(
(setting the mime-type to 'audio/wav' in the cordova-plugin-media creates a "corrupt" wav file, still amr-encode when analyzing it further with a tool...)
I really appreciate your help!
I came up with a "solution", which I share with you if someone else is running in the same problems as I did:
www.cloudconvert.com offers a very simple api for "on-the-fly" converting video/audio/img files.
For node.js there is a node package for that I can recommend: https://github.com/cloudconvert/cloudconvert-node
I decided to convert the .amr to .mp3 and not .wav (iOS "standard") since .mp3 is smaller. To be able to play it on an iOS device though one has to adjust the bitrate a little bit from the (manual) example described on github.
Make sure to pass the following options to your converting process:
ccprocess.start({
outputformat: 'mp3',
input: 'download',
file: 'path-to-your-file',
converteroptions: {
audio_bitrate: "721",
audio_frequency: "44100",
audio_qscale: -1
}
}, function (err, ccprocess) { ...

CURLE_PARTIAL_FILE error for large files with libcurl

I have linked libcurl library (v7.38.0) statically with my C++
application. Using curl, we upload & download files to/from server https. I Have
download fails with the error CURLE_PARTIAL_FILE. This issue occurs
randomly ie., some times the file was downloaded successfully without
issue and some times, the same file fails with the error.
This issue occurs in android platforms. Anyone can show me how to fix that
CURLE_PARTIAL_FILE means that the transfer was aborted before the full contents arrived. That typically means a bad server or a network problem, not a client-side problem.
If you cannot affect the network or server conditions, you probably need to consider ignoring this particular error.

Downloading fails much more frequently on iOS than on Android?

In my iOS project, I use NSURLConnection to download files. My code is just like the http://developer.apple.com/library/ios/#documentation/Cocoa/Conceptual/URLLoadingSystem/Tasks/UsingNSURLConnection.html document.
In my team's Android project, we use Android's API to download the same files. Nothing special either.
Both the iOS and Android project have the same fail-retry mechanism, and both of them send the same statistic data to server.
The files they trying to download is between 1M to 10M.
The statistic server shows that for the same URL, download failure is 2% on android, but 20% on iOS! Since they are trying to download the same URL, it seems not the server's problem but more like a client issue.
Why iOS download would fail so frequently? Is there any special APIs I should use for iOS, to make the download robust? Currently I'm using NSURLConnection, and I've just found NSURLDownloader which is more convenient to write files. Will they be different for download success percentage?
P.S. the error I got by -
(void) connection: (NSURLConnection *) connection didFailWithError: (NSError *) , is usually -1005, NSURLErrorNetworkConnectionLost.
I'd suggest looking more into why you're getting NSURLErrorNetworkConnectionLost. Even if your device says it's connected, sometimes it could lose the connection and be attempting to regain it before the indicators update accordingly.
This is a good starting point for more information on better dealing with reachability. Checking For Internet Connectivity in Objective C
Otherwise, I recommend you post your download-related code so others can look for possible issues.

Categories

Resources