INSTRUCTION stringlengths 1 8.43k | RESPONSE stringlengths 75 104k |
|---|---|
Copy necessary variables to pre - allocated memory section. | def pack_args_by_32(holder, maxlen, arg, typ, context, placeholder,
dynamic_offset_counter=None, datamem_start=None, zero_pad_i=None, pos=None):
"""
Copy necessary variables to pre-allocated memory section.
:param holder: Complete holder for all args
:param maxlen: Total length in b... |
Validates a version pragma directive against the current compiler version. | def validate_version_pragma(version_str: str, start: ParserPosition) -> None:
"""
Validates a version pragma directive against the current compiler version.
"""
from vyper import (
__version__,
)
version_arr = version_str.split('@version')
file_version = version_arr[1].strip()
... |
Re - formats a vyper source string into a python source string and performs some validation. More specifically | def pre_parse(code: str) -> Tuple[ClassTypes, str]:
"""
Re-formats a vyper source string into a python source string and performs
some validation. More specifically,
* Translates "contract" and "struct" keyword into python "class" keyword
* Validates "@version" pragma against current compiler vers... |
Valid variable name checked against global context. | def is_valid_varname(self, name, item):
""" Valid variable name, checked against global context. """
check_valid_varname(name, self._custom_units, self._structs, self._constants, item)
if name in self._globals:
raise VariableDeclarationException(
'Invalid name "%s", p... |
Nonrentrant locks use a prefix with a counter to minimise deployment cost of a contract. | def get_nonrentrant_counter(self, key):
"""
Nonrentrant locks use a prefix with a counter to minimise deployment cost of a contract.
"""
prefix = NONRENTRANT_STORAGE_OFFSET
if key in self._nonrentrant_keys:
return self._nonrentrant_keys[key]
else:
... |
Test if the current statement is a type of list used in for loops. | def _is_list_iter(self):
"""
Test if the current statement is a type of list, used in for loops.
"""
# Check for literal or memory list.
iter_var_type = (
self.context.vars.get(self.stmt.iter.id).typ
if isinstance(self.stmt.iter, ast.Name)
els... |
Return unrolled const | def get_constant(self, const_name, context):
""" Return unrolled const """
# check if value is compatible with
const = self._constants[const_name]
if isinstance(const, ast.AnnAssign): # Handle ByteArrays.
if context:
expr = Expr(const.value, context).lll_no... |
Using a list of args determine the most accurate signature to use from the given context | def lookup_sig(cls, sigs, method_name, expr_args, stmt_or_expr, context):
"""
Using a list of args, determine the most accurate signature to use from
the given context
"""
def synonymise(s):
return s.replace('int128', 'num').replace('uint256', 'num')
# for s... |
Performs annotation and optimization on a parsed python AST by doing the following: | def annotate_and_optimize_ast(
parsed_ast: ast.Module,
source_code: str,
class_types: Optional[ClassTypes] = None,
) -> None:
"""
Performs annotation and optimization on a parsed python AST by doing the
following:
* Annotating all AST nodes with the originating source code of the AST
* ... |
Handle invalid variable names | def check_valid_varname(varname,
custom_units,
custom_structs,
constants,
pos,
error_prefix="Variable name invalid.",
exc=None):
""" Handle invalid variable names """
e... |
Allocate a MID which has not been used yet. | def allocate_mid(mids):
"""
Allocate a MID which has not been used yet.
"""
i = 0
while True:
mid = str(i)
if mid not in mids:
mids.add(mid)
return mid
i += 1 |
Add a new: class: RTCIceCandidate received from the remote peer. | def addIceCandidate(self, candidate):
"""
Add a new :class:`RTCIceCandidate` received from the remote peer.
The specified candidate must have a value for either `sdpMid` or `sdpMLineIndex`.
"""
if candidate.sdpMid is None and candidate.sdpMLineIndex is None:
raise Va... |
Add a: class: MediaStreamTrack to the set of media tracks which will be transmitted to the remote peer. | def addTrack(self, track):
"""
Add a :class:`MediaStreamTrack` to the set of media tracks which
will be transmitted to the remote peer.
"""
# check state is valid
self.__assertNotClosed()
if track.kind not in ['audio', 'video']:
raise InternalError('In... |
Add a new: class: RTCRtpTransceiver. | def addTransceiver(self, trackOrKind, direction='sendrecv'):
"""
Add a new :class:`RTCRtpTransceiver`.
"""
self.__assertNotClosed()
# determine track or kind
if hasattr(trackOrKind, 'kind'):
kind = trackOrKind.kind
track = trackOrKind
else... |
Terminate the ICE agent ending ICE processing and streams. | async def close(self):
"""
Terminate the ICE agent, ending ICE processing and streams.
"""
if self.__isClosed:
return
self.__isClosed = True
self.__setSignalingState('closed')
# stop senders / receivers
for transceiver in self.__transceivers:
... |
Create an SDP answer to an offer received from a remote peer during the offer/ answer negotiation of a WebRTC connection. | async def createAnswer(self):
"""
Create an SDP answer to an offer received from a remote peer during
the offer/answer negotiation of a WebRTC connection.
:rtype: :class:`RTCSessionDescription`
"""
# check state is valid
self.__assertNotClosed()
if self.s... |
Create a data channel with the given label. | def createDataChannel(self, label, maxPacketLifeTime=None, maxRetransmits=None,
ordered=True, protocol='', negotiated=False, id=None):
"""
Create a data channel with the given label.
:rtype: :class:`RTCDataChannel`
"""
if maxPacketLifeTime is not None a... |
Create an SDP offer for the purpose of starting a new WebRTC connection to a remote peer. | async def createOffer(self):
"""
Create an SDP offer for the purpose of starting a new WebRTC
connection to a remote peer.
:rtype: :class:`RTCSessionDescription`
"""
# check state is valid
self.__assertNotClosed()
if not self.__sctp and not self.__transc... |
Returns statistics for the connection. | async def getStats(self):
"""
Returns statistics for the connection.
:rtype: :class:`RTCStatsReport`
"""
merged = RTCStatsReport()
coros = [x.getStats() for x in (self.getSenders() + self.getReceivers())]
for report in await asyncio.gather(*coros):
me... |
Change the local description associated with the connection. | async def setLocalDescription(self, sessionDescription):
"""
Change the local description associated with the connection.
:param: sessionDescription: An :class:`RTCSessionDescription` generated
by :meth:`createOffer` or :meth:`createAnswer()`.
"""
... |
Changes the remote description associated with the connection. | async def setRemoteDescription(self, sessionDescription):
"""
Changes the remote description associated with the connection.
:param: sessionDescription: An :class:`RTCSessionDescription` created from
information received over the signaling channel.
""... |
Pack the FCI for a Receiver Estimated Maximum Bitrate report. | def pack_remb_fci(bitrate, ssrcs):
"""
Pack the FCI for a Receiver Estimated Maximum Bitrate report.
https://tools.ietf.org/html/draft-alvestrand-rmcat-remb-03
"""
data = b'REMB'
exponent = 0
mantissa = bitrate
while mantissa > 0x3ffff:
mantissa >>= 1
exponent += 1
d... |
Unpack the FCI for a Receiver Estimated Maximum Bitrate report. | def unpack_remb_fci(data):
"""
Unpack the FCI for a Receiver Estimated Maximum Bitrate report.
https://tools.ietf.org/html/draft-alvestrand-rmcat-remb-03
"""
if len(data) < 8 or data[0:4] != b'REMB':
raise ValueError('Invalid REMB prefix')
exponent = (data[5] & 0xfc) >> 2
mantissa ... |
Parse header extensions according to RFC 5285. | def unpack_header_extensions(extension_profile: int,
extension_value: bytes) -> List[Tuple[int, bytes]]:
"""
Parse header extensions according to RFC 5285.
"""
extensions = []
pos = 0
if extension_profile == 0xBEDE:
# One-Byte Header
while pos < len(... |
Serialize header extensions according to RFC 5285. | def pack_header_extensions(extensions: List[Tuple[int, bytes]]) -> Tuple[int, bytes]:
"""
Serialize header extensions according to RFC 5285.
"""
extension_profile = 0
extension_value = b''
if not extensions:
return extension_profile, extension_value
one_byte = True
for x_id, x_... |
Recover initial packet from a retransmission packet. | def unwrap_rtx(rtx, payload_type, ssrc):
"""
Recover initial packet from a retransmission packet.
"""
packet = RtpPacket(
payload_type=payload_type,
marker=rtx.marker,
sequence_number=unpack('!H', rtx.payload[0:2])[0],
timestamp=rtx.timestamp,
ssrc=ssrc,
p... |
Create a retransmission packet from a lost packet. | def wrap_rtx(packet, payload_type, sequence_number, ssrc):
"""
Create a retransmission packet from a lost packet.
"""
rtx = RtpPacket(
payload_type=payload_type,
marker=packet.marker,
sequence_number=sequence_number,
timestamp=packet.timestamp,
ssrc=ssrc,
... |
Returns statistics about the RTP sender. | async def getStats(self):
"""
Returns statistics about the RTP sender.
:rtype: :class:`RTCStatsReport`
"""
self.__stats.add(RTCOutboundRtpStreamStats(
# RTCStats
timestamp=clock.current_datetime(),
type='outbound-rtp',
id='outbound... |
Attempt to set the parameters controlling the sending of media. | async def send(self, parameters: RTCRtpSendParameters):
"""
Attempt to set the parameters controlling the sending of media.
:param: parameters: The :class:`RTCRtpParameters` for the sender.
"""
if not self.__started:
self.__cname = parameters.rtcp.cname
s... |
Irreversibly stop the sender. | async def stop(self):
"""
Irreversibly stop the sender.
"""
if self.__started:
self.__transport._unregister_rtp_sender(self)
self.__rtp_task.cancel()
self.__rtcp_task.cancel()
await asyncio.gather(
self.__rtp_exited.wait(),
... |
Retransmit an RTP packet which was reported as lost. | async def _retransmit(self, sequence_number):
"""
Retransmit an RTP packet which was reported as lost.
"""
packet = self.__rtp_history.get(sequence_number % RTP_HISTORY_SIZE)
if packet and packet.sequence_number == sequence_number:
if self.__rtx_payload_type is not No... |
Return a > b. | def uint16_gt(a: int, b: int) -> bool:
"""
Return a > b.
"""
half_mod = 0x8000
return (((a < b) and ((b - a) > half_mod)) or
((a > b) and ((a - b) < half_mod))) |
Return a > = b. | def uint16_gte(a: int, b: int) -> bool:
"""
Return a >= b.
"""
return (a == b) or uint16_gt(a, b) |
Return a > b. | def uint32_gt(a: int, b: int) -> bool:
"""
Return a > b.
"""
half_mod = 0x80000000
return (((a < b) and ((b - a) > half_mod)) or
((a > b) and ((a - b) < half_mod))) |
Return a > = b. | def uint32_gte(a: int, b: int) -> bool:
"""
Return a >= b.
"""
return (a == b) or uint32_gt(a, b) |
Bring up interface. Equivalent to ifconfig [ iface ] up. | def up(self):
''' Bring up interface. Equivalent to ifconfig [iface] up. '''
# Set new flags
flags = self.ifflags | IFF_UP
self.ifflags = flags
self.get_mtu() |
Open file corresponding to the TUN device. | def open(self):
''' Open file corresponding to the TUN device. '''
self.fd = open('/dev/net/tun', 'rb+', buffering=0)
tun_flags = IFF_TAP | IFF_NO_PI | IFF_PERSIST
ifr = struct.pack('16sH', self.name, tun_flags)
fcntl.ioctl(self.fd, TUNSETIFF, ifr)
fcntl.ioctl(self.fd, TU... |
Gather ICE candidates. | async def gather(self):
"""
Gather ICE candidates.
"""
if self.__state == 'new':
self.__setState('gathering')
await self._connection.gather_candidates()
self.__setState('completed') |
Retrieve the ICE parameters of the ICE gatherer. | def getLocalParameters(self):
"""
Retrieve the ICE parameters of the ICE gatherer.
:rtype: RTCIceParameters
"""
return RTCIceParameters(
usernameFragment=self._connection.local_username,
password=self._connection.local_password) |
Add a remote candidate. | def addRemoteCandidate(self, candidate):
"""
Add a remote candidate.
"""
# FIXME: don't use private member!
if not self._connection._remote_candidates_end:
if candidate is None:
self._connection.add_remote_candidate(None)
else:
... |
Initiate connectivity checks. | async def start(self, remoteParameters):
"""
Initiate connectivity checks.
:param: remoteParameters: The :class:`RTCIceParameters` associated with
the remote :class:`RTCIceTransport`.
"""
if self.state == 'closed':
raise InvalidState... |
Send data across the data channel to the remote peer. | def send(self, data):
"""
Send `data` across the data channel to the remote peer.
"""
if self.readyState != 'open':
raise InvalidStateError
if not isinstance(data, (str, bytes)):
raise ValueError('Cannot send unsupported data type: %s' % type(data))
... |
Override the default codec preferences. | def setCodecPreferences(self, codecs):
"""
Override the default codec preferences.
See :meth:`RTCRtpSender.getCapabilities` and :meth:`RTCRtpReceiver.getCapabilities`
for the supported codecs.
:param: codecs: A list of :class:`RTCRtpCodecCapability`, in decreasing order
... |
Permanently stops the: class: RTCRtpTransceiver. | async def stop(self):
"""
Permanently stops the :class:`RTCRtpTransceiver`.
"""
await self.__receiver.stop()
await self.__sender.stop()
self.__stopped = True |
Start discarding media. | async def start(self):
"""
Start discarding media.
"""
for track, task in self.__tracks.items():
if task is None:
self.__tracks[track] = asyncio.ensure_future(blackhole_consume(track)) |
Stop discarding media. | async def stop(self):
"""
Stop discarding media.
"""
for task in self.__tracks.values():
if task is not None:
task.cancel()
self.__tracks = {} |
Add a track to be recorded. | def addTrack(self, track):
"""
Add a track to be recorded.
:param: track: An :class:`aiortc.AudioStreamTrack` or :class:`aiortc.VideoStreamTrack`.
"""
if track.kind == 'audio':
if self.__container.format.name == 'wav':
codec_name = 'pcm_s16le'
... |
Start recording. | async def start(self):
"""
Start recording.
"""
for track, context in self.__tracks.items():
if context.task is None:
context.task = asyncio.ensure_future(self.__run_track(track, context)) |
Stop recording. | async def stop(self):
"""
Stop recording.
"""
if self.__container:
for track, context in self.__tracks.items():
if context.task is not None:
context.task.cancel()
context.task = None
for packet in con... |
The date and time after which the certificate will be considered invalid. | def expires(self):
"""
The date and time after which the certificate will be considered invalid.
"""
not_after = self._cert.get_notAfter().decode('ascii')
return datetime.datetime.strptime(not_after, '%Y%m%d%H%M%SZ').replace(
tzinfo=datetime.timezone.utc) |
Create and return an X. 509 certificate and corresponding private key. | def generateCertificate(cls):
"""
Create and return an X.509 certificate and corresponding private key.
:rtype: RTCCertificate
"""
key = generate_key()
cert = generate_certificate(key)
return cls(key=key, cert=cert) |
Start DTLS transport negotiation with the parameters of the remote DTLS transport. | async def start(self, remoteParameters):
"""
Start DTLS transport negotiation with the parameters of the remote
DTLS transport.
:param: remoteParameters: An :class:`RTCDtlsParameters`.
"""
assert self._state == State.NEW
assert len(remoteParameters.fingerprints)
... |
Stop and close the DTLS transport. | async def stop(self):
"""
Stop and close the DTLS transport.
"""
if self._task is not None:
self._task.cancel()
self._task = None
if self._state in [State.CONNECTING, State.CONNECTED]:
lib.SSL_shutdown(self.ssl)
try:
... |
Flush outgoing data which OpenSSL put in our BIO to the transport. | async def _write_ssl(self):
"""
Flush outgoing data which OpenSSL put in our BIO to the transport.
"""
pending = lib.BIO_ctrl_pending(self.write_bio)
if pending > 0:
result = lib.BIO_read(self.write_bio, self.write_cdata, len(self.write_cdata))
await self.... |
For testing purposes. | def set_estimate(self, bitrate: int, now_ms: int):
"""
For testing purposes.
"""
self.current_bitrate = self._clamp_bitrate(bitrate, bitrate)
self.current_bitrate_initialized = True
self.last_change_ms = now_ms |
Receive the next: class: ~av. audio. frame. AudioFrame. | async def recv(self):
"""
Receive the next :class:`~av.audio.frame.AudioFrame`.
The base implementation just reads silence, subclass
:class:`AudioStreamTrack` to provide a useful implementation.
"""
if self.readyState != 'live':
raise MediaStreamError
... |
Receive the next: class: ~av. video. frame. VideoFrame. | async def recv(self):
"""
Receive the next :class:`~av.video.frame.VideoFrame`.
The base implementation just reads a 640x480 green frame at 30fps,
subclass :class:`VideoStreamTrack` to provide a useful implementation.
"""
pts, time_base = await self.next_timestamp()
... |
Prune chunks up to the given TSN. | def prune_chunks(self, tsn):
"""
Prune chunks up to the given TSN.
"""
pos = -1
size = 0
for i, chunk in enumerate(self.reassembly):
if uint32_gte(tsn, chunk.tsn):
pos = i
size += len(chunk.user_data)
else:
... |
Start the transport. | async def start(self, remoteCaps, remotePort):
"""
Start the transport.
"""
if not self.__started:
self.__started = True
self.__state = 'connecting'
self._remote_port = remotePort
# configure logging
if logger.isEnabledFor(logg... |
Stop the transport. | async def stop(self):
"""
Stop the transport.
"""
if self._association_state != self.State.CLOSED:
await self._abort()
self.__transport._unregister_data_receiver(self)
self._set_state(self.State.CLOSED) |
Initialize the association. | async def _init(self):
"""
Initialize the association.
"""
chunk = InitChunk()
chunk.initiate_tag = self._local_verification_tag
chunk.advertised_rwnd = self._advertised_rwnd
chunk.outbound_streams = self._outbound_streams_count
chunk.inbound_streams = sel... |
Gets what extensions are supported by the remote party. | def _get_extensions(self, params):
"""
Gets what extensions are supported by the remote party.
"""
for k, v in params:
if k == SCTP_PRSCTP_SUPPORTED:
self._remote_partial_reliability = True
elif k == SCTP_SUPPORTED_CHUNK_EXT:
self._... |
Sets what extensions are supported by the local party. | def _set_extensions(self, params):
"""
Sets what extensions are supported by the local party.
"""
extensions = []
if self._local_partial_reliability:
params.append((SCTP_PRSCTP_SUPPORTED, b''))
extensions.append(ForwardTsnChunk.type)
extensions.ap... |
Get or create the inbound stream with the specified ID. | def _get_inbound_stream(self, stream_id):
"""
Get or create the inbound stream with the specified ID.
"""
if stream_id not in self._inbound_streams:
self._inbound_streams[stream_id] = InboundStream()
return self._inbound_streams[stream_id] |
Handle data received from the network. | async def _handle_data(self, data):
"""
Handle data received from the network.
"""
try:
_, _, verification_tag, chunks = parse_packet(data)
except ValueError:
return
# is this an init?
init_chunk = len([x for x in chunks if isinstance(x, I... |
Determine if a chunk needs to be marked as abandoned. | def _maybe_abandon(self, chunk):
"""
Determine if a chunk needs to be marked as abandoned.
If it does, it marks the chunk and any other chunk belong to the same
message as abandoned.
"""
if chunk._abandoned:
return True
abandon = (
(chunk... |
Mark an incoming data TSN as received. | def _mark_received(self, tsn):
"""
Mark an incoming data TSN as received.
"""
# it's a duplicate
if uint32_gte(self._last_received_tsn, tsn) or tsn in self._sack_misordered:
self._sack_duplicates.append(tsn)
return True
# consolidate misordered en... |
Receive data stream - > ULP. | async def _receive(self, stream_id, pp_id, data):
"""
Receive data stream -> ULP.
"""
await self._data_channel_receive(stream_id, pp_id, data) |
Handle an incoming chunk. | async def _receive_chunk(self, chunk):
"""
Handle an incoming chunk.
"""
self.__log_debug('< %s', chunk)
# common
if isinstance(chunk, DataChunk):
await self._receive_data_chunk(chunk)
elif isinstance(chunk, SackChunk):
await self._receive... |
Handle a DATA chunk. | async def _receive_data_chunk(self, chunk):
"""
Handle a DATA chunk.
"""
self._sack_needed = True
# mark as received
if self._mark_received(chunk.tsn):
return
# find stream
inbound_stream = self._get_inbound_stream(chunk.stream_id)
#... |
Handle a FORWARD TSN chunk. | async def _receive_forward_tsn_chunk(self, chunk):
"""
Handle a FORWARD TSN chunk.
"""
self._sack_needed = True
# it's a duplicate
if uint32_gte(self._last_received_tsn, chunk.cumulative_tsn):
return
def is_obsolete(x):
return uint32_gt(x... |
Handle a SACK chunk. | async def _receive_sack_chunk(self, chunk):
"""
Handle a SACK chunk.
"""
if uint32_gt(self._last_sacked_tsn, chunk.cumulative_tsn):
return
received_time = time.time()
self._last_sacked_tsn = chunk.cumulative_tsn
cwnd_fully_utilized = (self._flight_siz... |
Handle a RE - CONFIG parameter. | async def _receive_reconfig_param(self, param):
"""
Handle a RE-CONFIG parameter.
"""
self.__log_debug('<< %s', param)
if isinstance(param, StreamResetOutgoingParam):
# mark closed inbound streams
for stream_id in param.streams:
self._inbo... |
Send data ULP - > stream. | async def _send(self, stream_id, pp_id, user_data,
expiry=None, max_retransmits=None, ordered=True):
"""
Send data ULP -> stream.
"""
if ordered:
stream_seq = self._outbound_stream_seq.get(stream_id, 0)
else:
stream_seq = 0
fra... |
Transmit a chunk ( no bundling for now ). | async def _send_chunk(self, chunk):
"""
Transmit a chunk (no bundling for now).
"""
self.__log_debug('> %s', chunk)
await self.__transport._send_data(serialize_packet(
self._local_port,
self._remote_port,
self._remote_verification_tag,
... |
Build and send a selective acknowledgement ( SACK ) chunk. | async def _send_sack(self):
"""
Build and send a selective acknowledgement (SACK) chunk.
"""
gaps = []
gap_next = None
for tsn in sorted(self._sack_misordered):
pos = (tsn - self._last_received_tsn) % SCTP_TSN_MODULO
if tsn == gap_next:
... |
Transition the SCTP association to a new state. | def _set_state(self, state):
"""
Transition the SCTP association to a new state.
"""
if state != self._association_state:
self.__log_debug('- %s -> %s', self._association_state, state)
self._association_state = state
if state == self.State.ESTABLISHED:
... |
Transmit outbound data. | async def _transmit(self):
"""
Transmit outbound data.
"""
# send FORWARD TSN
if self._forward_tsn_chunk is not None:
await self._send_chunk(self._forward_tsn_chunk)
self._forward_tsn_chunk = None
# ensure T3 is running
if not self... |
Try to advance Advanced. Peer. Ack. Point according to RFC 3758. | def _update_advanced_peer_ack_point(self):
"""
Try to advance "Advanced.Peer.Ack.Point" according to RFC 3758.
"""
if uint32_gt(self._last_sacked_tsn, self._advanced_peer_ack_tsn):
self._advanced_peer_ack_tsn = self._last_sacked_tsn
done = 0
streams = {}
... |
Update RTO given a new roundtrip measurement R. | def _update_rto(self, R):
"""
Update RTO given a new roundtrip measurement R.
"""
if self._srtt is None:
self._rttvar = R / 2
self._srtt = R
else:
self._rttvar = (1 - SCTP_RTO_BETA) * self._rttvar + SCTP_RTO_BETA * abs(self._srtt - R)
... |
Request closing the datachannel by sending an Outgoing Stream Reset Request. | def _data_channel_close(self, channel, transmit=True):
"""
Request closing the datachannel by sending an Outgoing Stream Reset Request.
"""
if channel.readyState not in ['closing', 'closed']:
channel._setReadyState('closing')
self._reconfig_queue.append(channel.id... |
Try to flush buffered data to the SCTP layer. | async def _data_channel_flush(self):
"""
Try to flush buffered data to the SCTP layer.
We wait until the association is established, as we need to know
whether we are a client or a server to correctly assign an odd/even ID
to the data channels.
"""
if self._assoc... |
Add signaling method arguments to an argparse. ArgumentParser. | def add_signaling_arguments(parser):
"""
Add signaling method arguments to an argparse.ArgumentParser.
"""
parser.add_argument('--signaling', '-s', choices=[
'copy-and-paste', 'tcp-socket', 'unix-socket'])
parser.add_argument('--signaling-host', default='127.0.0.1',
h... |
Create a signaling method based on command - line arguments. | def create_signaling(args):
"""
Create a signaling method based on command-line arguments.
"""
if args.signaling == 'tcp-socket':
return TcpSocketSignaling(args.signaling_host, args.signaling_port)
elif args.signaling == 'unix-socket':
return UnixSocketSignaling(args.signaling_path)
... |
Receive the next frame. | async def recv(self):
"""
Receive the next frame.
"""
if self.readyState != 'live':
raise MediaStreamError
frame = await self._queue.get()
if frame is None:
self.stop()
raise MediaStreamError
return frame |
Returns statistics about the RTP receiver. | async def getStats(self):
"""
Returns statistics about the RTP receiver.
:rtype: :class:`RTCStatsReport`
"""
for ssrc, stream in self.__remote_streams.items():
self.__stats.add(RTCInboundRtpStreamStats(
# RTCStats
timestamp=clock.curre... |
Returns a: class: RTCRtpSynchronizationSource for each unique SSRC identifier received in the last 10 seconds. | def getSynchronizationSources(self):
"""
Returns a :class:`RTCRtpSynchronizationSource` for each unique SSRC identifier
received in the last 10 seconds.
"""
cutoff = clock.current_datetime() - datetime.timedelta(seconds=10)
sources = []
for source, timestamp in se... |
Attempt to set the parameters controlling the receiving of media. | async def receive(self, parameters: RTCRtpReceiveParameters):
"""
Attempt to set the parameters controlling the receiving of media.
:param: parameters: The :class:`RTCRtpParameters` for the receiver.
"""
if not self.__started:
for codec in parameters.codecs:
... |
Irreversibly stop the receiver. | async def stop(self):
"""
Irreversibly stop the receiver.
"""
if self.__started:
self.__transport._unregister_rtp_receiver(self)
self.__stop_decoder()
self.__rtcp_task.cancel()
await self.__rtcp_exited.wait() |
Handle an incoming RTP packet. | async def _handle_rtp_packet(self, packet: RtpPacket, arrival_time_ms: int):
"""
Handle an incoming RTP packet.
"""
self.__log_debug('< %s', packet)
# feed bitrate estimator
if self.__remote_bitrate_estimator is not None:
if packet.extensions.abs_send_time is... |
Send an RTCP packet to report missing RTP packets. | async def _send_rtcp_nack(self, media_ssrc, lost):
"""
Send an RTCP packet to report missing RTP packets.
"""
if self.__rtcp_ssrc is not None:
packet = RtcpRtpfbPacket(
fmt=RTCP_RTPFB_NACK, ssrc=self.__rtcp_ssrc, media_ssrc=media_ssrc)
packet.lost ... |
Send an RTCP packet to report picture loss. | async def _send_rtcp_pli(self, media_ssrc):
"""
Send an RTCP packet to report picture loss.
"""
if self.__rtcp_ssrc is not None:
packet = RtcpPsfbPacket(fmt=RTCP_PSFB_PLI, ssrc=self.__rtcp_ssrc, media_ssrc=media_ssrc)
await self._send_rtcp(packet) |
Stop the decoder thread which will in turn stop the track. | def __stop_decoder(self):
"""
Stop the decoder thread, which will in turn stop the track.
"""
if self.__decoder_thread:
self.__decoder_queue.put(None)
self.__decoder_thread.join()
self.__decoder_thread = None |
This is usually an implementation of Ledger | def init_domain_ledger(self):
"""
This is usually an implementation of Ledger
"""
if self.config.primaryStorage is None:
genesis_txn_initiator = GenesisTxnInitiatorFromFile(
self.genesis_dir, self.config.domainTransactionsFile)
return Ledger(
... |
All the data of the transaction might not be stored in ledger so the extra data that is omitted from ledger needs to be fetched from the appropriate data store: param txn:: return: | def update_txn_with_extra_data(self, txn):
"""
All the data of the transaction might not be stored in ledger so the
extra data that is omitted from ledger needs to be fetched from the
appropriate data store
:param txn:
:return:
"""
# For RAW and ENC attrib... |
Make key ( path ) - value pair for state from ATTRIB or GET_ATTR: return: state path state value value for attribute store | def prepare_attr_for_state(txn, path_only=False):
"""
Make key(path)-value pair for state from ATTRIB or GET_ATTR
:return: state path, state value, value for attribute store
"""
assert get_type(txn) == ATTRIB
txn_data = get_payload_data(txn)
nym = txn_data[TARGET_NYM]
attr_type, attr_key... |
ATTR and GET_ATTR can have one of raw enc and hash fields. This method checks which of them presents and return it s name and value in it. | def _extract_attr_typed_value(txn_data):
"""
ATTR and GET_ATTR can have one of 'raw', 'enc' and 'hash' fields.
This method checks which of them presents and return it's name
and value in it.
"""
existing_keys = [key for key in ALL_ATR_KEYS if key in txn_data]
if len(existing_keys) == 0:
... |
Test for the directory open old and new ledger migrate data rename directories | def _migrate_ledger(data_directory,
old_ledger_file, new_ledger_file,
serializer: MappingSerializer = None):
"""
Test for the directory, open old and new ledger, migrate data, rename directories
"""
# we should have ChunkedFileStorage implementation of the Ledger... |
Get a nym if role is provided then get nym with that role: param nym:: param role:: param isCommitted:: return: | def getNym(self, nym, role=None, isCommitted=True):
"""
Get a nym, if role is provided then get nym with that role
:param nym:
:param role:
:param isCommitted:
:return:
"""
try:
seqNo, txnTime, ta, actual_role, verkey = self.get(nym, isCommitte... |
Unschedule current action | def _unscheduleAction(self):
"""
Unschedule current action
Note that it does not add record to action log and does not do
required steps to resume previous action. If you need this - use
_cancelScheduledAction
"""
logger.trace("{} unscheduling actions".format(se... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.