Skip to content

Commit

Permalink
gstreamer.py code improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
rsanchez87 committed Jul 5, 2024
1 parent 466c1b4 commit 998ec02
Showing 1 changed file with 11 additions and 19 deletions.
30 changes: 11 additions & 19 deletions fluster/decoders/gstreamer.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ def gst_element_exists(element: str) -> bool:
return True
except (subprocess.CalledProcessError, FileNotFoundError):
return False
return False


def output_format_to_gst(output_format: OutputFormat) -> str:
Expand Down Expand Up @@ -114,25 +113,18 @@ def gen_pipeline(
def parse_videocodectestsink_md5sum(self, data: List[str]) -> str:
"""Parse the MD5 sum out of commandline output produced when using
videocodectestsink."""
pattern = "conformance/checksum, checksum-type=(string)MD5, checksum=(string)"
# Iterate over each line in the data
for line in data:
pattern = (
"conformance/checksum, checksum-type=(string)MD5, checksum=(string)"
)
sum_start = line.find(pattern)
# pylint: disable=no-else-continue
if sum_start <= 0:
# Skip to the next iteration if sum_start is less than or equal to 0
continue
else:
sum_start += len(pattern)
sum_end = line[sum_start:].find(";")
# pylint: disable=no-else-continue
if sum_end <= 0:
# Skip to the next iteration if sum_end is less than or equal to 0
continue
else:
sum_end += sum_start
return line[sum_start:sum_end]
# Partition the line into three parts: before the pattern, the pattern, and after the pattern
before, match, after = line.partition(pattern)
# If the pattern is found (match is not empty)
if match:
# Partition the remaining part to find the checksum up to the first ';'
checksum, _, _ = after.partition(";")
# If a valid checksum is found
if checksum:
return checksum

raise Exception("No MD5 found in the program trace.")

Expand Down

0 comments on commit 998ec02

Please sign in to comment.