Skip to content

Commit

Permalink
Server push: Download segments while client requests for manifest. Ad…
Browse files Browse the repository at this point in the history
…apt playback and decode according to it as well

- TODO: Currently, server sends a fake request to itself to announce server push. We need to the create and capture the response for that fake request and retrieve the data in the client. While right now, the server tells the client to blindly believe that the server pushed data is readily available for the client in cache or other location
  • Loading branch information
Aniketh01 committed Sep 6, 2020
1 parent cc98c4e commit c9bdd83
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 5 deletions.
6 changes: 4 additions & 2 deletions clients/dash_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ async def fetchNextSegment(self, segment_list, bitrate = 0):

for fname in sorted(glob(segment_list)):
_, self.segment_baseName = fname.rsplit('/', 1)
self.args.urls[0] = self.baseUrl + '/' + str(os.stat(fname).st_size)
self.args.urls[0] = self.baseUrl.rstrip('manifest') + str(os.stat(fname).st_size)
start = time.time()

res = await perform_http_request(client=self.protocol,
Expand Down Expand Up @@ -179,10 +179,12 @@ async def fetchNextSegment(self, segment_list, bitrate = 0):
async def download_segment(self) -> None:
if config.NUM_SERVER_PUSHED_FRAMES is not None:
self.currentSegment = config.NUM_SERVER_PUSHED_FRAMES + 1
for i in range(1, config.NUM_SERVER_PUSHED_FRAMES + 1):
await self.segmentQueue.put("Frame-pushed-" + str(i) + ".ppm")
else:
self.currentSegment += 1

while self.currentSegment < self.totalSegments:
while self.currentSegment <= self.totalSegments:
async with self.lock:
currBuff = self.currBuffer

Expand Down
2 changes: 1 addition & 1 deletion config.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Can provide a list of manifest to download via HTTP/3
URLS = ['https://localhost:4433/']

NUM_SERVER_PUSHED_FRAMES = 10
NUM_SERVER_PUSHED_FRAMES = 3

MANIFEST_FILE = "/home/aniketh/devel/src/abr-over-quic/htdocs/bbb_m.json"
CA_CERTS = "tests/pycacert.pem"
Expand Down
22 changes: 20 additions & 2 deletions demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,27 @@

import datetime
import os
import json
from urllib.parse import urlencode

import httpbin
from asgiref.wsgi import WsgiToAsgi
from starlette.applications import Starlette
from starlette.responses import PlainTextResponse, Response
from starlette.responses import PlainTextResponse, Response, JSONResponse
from starlette.staticfiles import StaticFiles
from starlette.templating import Jinja2Templates
from starlette.websockets import WebSocketDisconnect

import config

ROOT = os.path.dirname(__file__)
STATIC_ROOT = os.environ.get("STATIC_ROOT", os.path.join(ROOT, "htdocs"))
STATIC_URL = "/"
LOGS_PATH = os.path.join(STATIC_ROOT, "logs")
QVIS_URL = "https://qvis.edm.uhasselt.be/"

templates = Jinja2Templates(directory=os.path.join(STATIC_ROOT, "templates"))
app = Starlette()
app = Starlette(debug=True)


@app.route("/")
Expand All @@ -32,6 +35,21 @@ async def homepage(request):
await request.send_push_promise("/style.css")
return templates.TemplateResponse("index.html", {"request": request})

@app.route("/manifest/{filename:str}")
async def manifest(request):
server_pushed = 0

filename = request.path_params['filename']
manifest = json.load(open(STATIC_ROOT + "/" + filename))
segment = manifest['segment_size_bytes'][0][2]

if config.NUM_SERVER_PUSHED_FRAMES is not None:
while server_pushed < config.NUM_SERVER_PUSHED_FRAMES:
await request.send_push_promise(str(segment))
server_pushed += 1

return JSONResponse(manifest)


@app.route("/echo", methods=["POST"])
async def echo(request):
Expand Down

0 comments on commit c9bdd83

Please # to comment.