Coverage for pyguymer3/media/does_media_have_RTP_hints.py: 68%

19 statements  

« prev     ^ index     » next       coverage.py v7.9.2, created at 2025-07-08 18:47 +0000

1#!/usr/bin/env python3 

2 

3# Define function ... 

4def does_media_have_RTP_hints( 

5 fname, 

6 /, 

7 *, 

8 cwd = None, 

9 debug = __debug__, 

10 ensureNFC = True, 

11 ffprobePath = None, 

12 playlist = -1, 

13 timeout = 60.0, 

14): 

15 # Import standard modules ... 

16 import shutil 

17 

18 # Import sub-functions ... 

19 from .__ffprobe__ import __ffprobe__ 

20 from .ffprobe import ffprobe 

21 

22 # ************************************************************************** 

23 

24 # Try to find the paths if the user did not provide them ... 

25 if ffprobePath is None: 

26 ffprobePath = shutil.which("ffprobe") 

27 assert ffprobePath is not None, "\"ffprobe\" is not installed" 

28 

29 # ************************************************************************** 

30 

31 # Make sure that this fname/playlist combination is in the global dictionary ... 

32 if fname not in __ffprobe__: 

33 __ffprobe__[fname] = {} 

34 if playlist not in __ffprobe__[fname]: 

35 if debug: 

36 print(f"INFO: Running ffprobe(\"{fname}\", {playlist:d}) ...") 

37 __ffprobe__[fname][playlist] = ffprobe( 

38 fname, 

39 cwd = cwd, 

40 ensureNFC = ensureNFC, 

41 ffprobePath = ffprobePath, 

42 playlist = playlist, 

43 timeout = timeout, 

44 ) 

45 

46 # Loop over streams ... 

47 for stream in __ffprobe__[fname][playlist]["streams"]: 

48 # Skip stream if it is not data ... 

49 if stream["codec_type"].strip().lower() != "data": 

50 continue 

51 

52 # Check if this data stream is RTP ... 

53 if stream["codec_tag_string"].strip().lower() == "rtp": 

54 # Return answer ... 

55 return True 

56 

57 # Return answer ... 

58 return False