Answered step by step
Verified Expert Solution
Question
1 Approved Answer
import java.io . FileWriter; import java.io . IOException; import java.util.Timer; import java.util.TimerTask; public class DASHClient { private static final String DASH _ MANIFEST _ URL
import java.ioFileWriter;
import java.ioIOException;
import java.util.Timer;
import java.util.TimerTask;
public class DASHClient
private static final String DASHMANIFESTURL https:ftpitec.aau.atdatasetsDASHDatasetBigBuckBunnysecBigBuckBunnysonDemandmpd;
private static final int BUFFERTHRESHOLD ; Buffer threshold for underrun detection
private double bufferDuration ;
private int chosenRepresentation ; Initial representation ID eg kbps
private double totalBitrate ;
private int underrunCount ;
private int underrunDuration ;
public static void mainString args
DASHClient client new DASHClient;
client.startStreaming;
private void startStreaming
Timer timer new Timer;
timer.scheduleAtFixedRatenew TimerTask
@Override
public void run
try
Fetch DASH manifest you can use HTTP client libraries
String manifestContent fetchDASHManifestDASHMANIFESTURL;
Parse manifest and choose representation simplified for demo
Assume representation IDs: kbps kbps kbps etc.
chosenRepresentation getNextRepresentationchosenRepresentation;
Simulate downloading video segments youd use a library
bufferDuration ;
totalBitrate getBitrateForRepresentationchosenRepresentation;
Check for underrun buffer depletion
if bufferDuration BUFFERTHRESHOLD
underrunCount;
underrunDuration;
Record data points write to a CSV file
recordDataPointSystemcurrentTimeMillis bufferDuration, chosenRepresentation,
getBitrateForRepresentationchosenRepresentation;
catch IOException e
eprintStackTrace;
; Run every second simulating realtime streaming
private String fetchDASHManifestString url throws IOException
Implement fetching logic eg using HttpURLConnection or HttpClient
Return the manifest content as a string
return ; Placeholder for demonstration
private int getNextRepresentationint currentRepId
Implement logic to switch to the next representation eg roundrobin
For simplicity, let's assume we cycle through representations:
return currentRepId ; Assuming representations kbps
private int getBitrateForRepresentationint repId
Map representation ID to actual bit rate you can adjust this based on your data
switch repId
case :
return ;
case :
return ;
case :
return ;
Add more cases for other representations if needed
default:
return ;
private void recordDataPointlong timestamp, double buffer, int repId, int bitrate
Create or open a CSV file for recording data points
try FileWriter writer new FileWriterstreamingdata.csv true
Append data to the file
writer.appendStringformatdfddn timestamp, buffer, repId, bitrate;
catch IOException e
eprintStackTrace;
above code is just simulating the real the time streaming instead of this write a code which actualy streams the given mpd file link and records the real time data
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started