2

I am developing an android video-streaming application where I must detect internet speed to adjust my stream quality according to that speed.

I've searched in the net about how to detect internet speed in android but I found only one method of downloading file and knowing its size to determine the bandwidth :

 bandwidth = contentLength / ((endTime-startTime) *1000);

Is there any other possible way to determine internet bandwith in android without downloading any file I don't want to disturb my video streaming by additional file downloading

Thanks.

sjain
  • 23,126
  • 28
  • 107
  • 185
Hadj Ali Oussama
  • 784
  • 2
  • 8
  • 29
  • 1
    how are you streaming the video, ie. what protocols are you using? changing the speed can be done dynamically if for example frames are not arriving in time reduce quality (using rtp/rtmp) – brendosthoughts May 02 '13 at 09:05
  • my point being that you are downloading frames, so you can determine sppeds using the method you've posted adapted to the frames from your video – brendosthoughts May 02 '13 at 09:11
  • frames are downloaded in my native code(its a new streaming protocol) and in my native code(c++) i can't access to informations about my device so i must use java to detect my bandwidth – Hadj Ali Oussama May 02 '13 at 09:20
  • a new streaming protocol? already installed on android devices? – brendosthoughts May 02 '13 at 09:27
  • its a long story it is a new streaming protocopl that i've intergrated in the aosp and tested it through my new media player successfully – Hadj Ali Oussama May 02 '13 at 09:30
  • and it provides no sort of feedback ass to what frames are in the buffer or what frames didn't arrive on time .. .these things will be essential to know what's going on at a network level. when streaming you must be able to adapt to changes in network on the fly these sort of metrics will be essential to get from some sort of api connected to the native code – brendosthoughts May 02 '13 at 10:10

1 Answers1

1

If you are on 2G,3G,4G, I don't think there is a standard way of finding out, maybe you can assume automatically that 2G,3G or 4G is slow.

If you are using wifi then you can calculate internet speed using WifiManager class

WifiInfo wifiInformation = wifiManger.getConnectionInfo();

and then from the WifiInfo you can get the current speed :

int speedInMbpsSpeed = wifiInformation.getLinkSpeed();

Tara
  • 692
  • 5
  • 23
Yogesh Rathi
  • 6,331
  • 4
  • 51
  • 81