Update RTSP server and examples to work with FFPLAY

This commit is contained in:
Kwabena W. Agyeman 2021-02-24 15:27:57 -08:00
parent c04b519e38
commit 1d10d9fa3a
2 changed files with 10 additions and 0 deletions

View File

@ -11,6 +11,8 @@ import network, omv, rtsp, sensor, time
# Not all programs (e.g. VLC) implement the full JPEG standard for decoding any JPEG image # Not all programs (e.g. VLC) implement the full JPEG standard for decoding any JPEG image
# in RTP packets. Images JPEG compressed by the OpenMV Cam internally may not display. # in RTP packets. Images JPEG compressed by the OpenMV Cam internally may not display.
# FFPLAY will correctly handle JPEGs produced by OpenMV software.
sensor.reset() sensor.reset()
sensor.set_pixformat(sensor.JPEG) # Only supported by the OV2640/OV5640. sensor.set_pixformat(sensor.JPEG) # Only supported by the OV2640/OV5640.

View File

@ -94,6 +94,13 @@ class rtsp_server:
if self.__pathname != '/' and self.__pathname.endswith('/'): if self.__pathname != '/' and self.__pathname.endswith('/'):
self.__pathname = self.__pathname[:-1] self.__pathname = self.__pathname[:-1]
if line0[2] == "RTSP/1.0": if line0[2] == "RTSP/1.0":
if len(s) >= 3 and s[1].split(' ')[0] != "CSeq:":
for i in range(2, len(s)):
if s[i].split(' ')[0] == "CSeq:":
temp = s[i]
s[i] = s[1]
s[1] = temp
break
line1 = s[1].split(' ') line1 = s[1].split(' ')
if line1[0] == "CSeq:": if line1[0] == "CSeq:":
seq = int(line1[1]) seq = int(line1[1])
@ -134,6 +141,7 @@ class rtsp_server:
if self.__setup_cb: self.__setup_cb(self.__pathname, self.__session) if self.__setup_cb: self.__setup_cb(self.__pathname, self.__session)
return return
elif request == "PLAY": elif request == "PLAY":
s = list(filter(lambda x: x and not x.startswith("Range"), s))
if len(s) >= 3: if len(s) >= 3:
m = re.match("Session: (\d+)", s[2]) m = re.match("Session: (\d+)", s[2])
if m: if m: