Skip to content

Commit

Permalink
Merge branch 'camera_client' of github.com:jlusiardi/homekit_python i…
Browse files Browse the repository at this point in the history
…nto camera_client
  • Loading branch information
jlusiardi committed Sep 16, 2020
2 parents a99f144 + 7001fa2 commit 5cfa672
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
17 changes: 8 additions & 9 deletions homekit/get_camera_stream.py
Expand Up @@ -48,23 +48,22 @@ def write_sdp_file(accessory_ip, video_port, audio_port):
'c=IN IP4 {a_ip}\n' \
'm=video {v_port} RTP/AVP 99\n' \
'a=rtpmap:99 H264/90000\n' \
'a=recvonly\n' \
'm=audio {a_port} RTP/AVP 110\n' \
'a=rtpmap:110 Opus/16000/1\n' \
'a=ptime:20\n' \
'a=maxptime:20\n'.format(a_ip=accessory_ip, v_port=video_port, a_port=audio_port)
f = tempfile.NamedTemporaryFile(delete=False, suffix='.sdp')
f = tempfile.NamedTemporaryFile(delete=False)
f.write(content.encode())
return f.name


def start_ffplay(sdp_file, master_key, master_salt):
print(master_key)
print(master_salt)
# blob = base64.b64encode(master_key + master_salt).decode()
command = ['ffplay', '-v', 'debug', '-sdp_flags', 'rtcp_to_source', sdp_file, '-protocol_whitelist',
'file,crypto,udp,rtp']
# command = ['cvlc', sdp_file, '--sout-rtp-rtcp-mux']
blob = base64.b64encode(master_key + master_salt).decode()
command = ['ffplay', '-f', 'sdp', sdp_file, '-protocol_whitelist',
'file,udp,rtp', '-srtp_in_suite',
'AES_CM_128_HMAC_SHA1_80', '-srtp_in_params', blob]
print(' '.join(command))
proc = subprocess.Popen(
command,
Expand All @@ -76,9 +75,10 @@ def start_ffplay(sdp_file, master_key, master_salt):
def start_ffmpeg(sdp_file, target, master_key, master_salt):
# '-s:v', '1280x720', '-r', '30',
# '-v', 'debug',
# blob = base64.b64encode(master_key + master_salt).decode('ascii')
blob = base64.b64encode(master_key + master_salt).decode('ascii')
command = ['ffmpeg', '-v', 'debug', '-protocol_whitelist', 'file,udp,rtp', '-i',
sdp_file, '-c', 'copy', '-shortest', '-y', target]
sdp_file, '-srtp_in_suite',
'AES_CM_128_HMAC_SHA1_80', '-srtp_in_params', blob, '-c', 'copy', '-shortest', '-y', target]
print(' '.join(command))
proc = subprocess.Popen(
command,
Expand Down Expand Up @@ -303,7 +303,6 @@ def get_random_port(default_port=None):
try:
time.sleep(1)
time_done += 1
print('time done:', time_done)
except KeyboardInterrupt:
break

Expand Down
7 changes: 5 additions & 2 deletions homekit/model/characteristics/supported_rtp_configuration.py
Expand Up @@ -16,10 +16,13 @@

import tlv8
from enum import IntEnum
from homekit.model.characteristics.characteristic_types import CharacteristicsTypes
from homekit.model.characteristics.setup_endpoints import CameraSRTPCryptoSuiteValues

CHARACTERISTIC_ID = CharacteristicsTypes.get_uuid(CharacteristicsTypes.SUPPORTED_RTP_CONFIGURATION)

class SupportedSrtpConfigurationKeys(IntEnum):

class SupportedRtpConfigurationKeys(IntEnum):
"""
Page 218 / Table 9-24
"""
Expand All @@ -28,5 +31,5 @@ class SupportedSrtpConfigurationKeys(IntEnum):

def decoder(bytes_data):
return tlv8.decode(bytes_data, {
SupportedSrtpConfigurationKeys.SRTP_CRYPTO_SUITE: CameraSRTPCryptoSuiteValues
SupportedRtpConfigurationKeys.SRTP_CRYPTO_SUITE: CameraSRTPCryptoSuiteValues
})

0 comments on commit 5cfa672

Please sign in to comment.