def _return_ctype(self):
""" Returns the associated ctype of a given datatype. """
_datatype_ctype = {
DataType.Bool: ctypes.c_uint8,
DataType.I8: ctypes.c_int8,
DataType.U8: ctypes.c_uint8,
DataType.I16: ctypes.c_int16,
DataType.U16: ctypes.c_uint16,
DataType.I32: ctypes.c_int32,
DataType.U32: ctypes.c_uint32,
DataType.I64: ctypes.c_int64,
DataType.U64: ctypes.c_uint64,
DataType.Sgl: ctypes.c_float,
DataType.Dbl: ctypes.c_double,
}
return _datatype_ctype[self]
python类c_int64()的实例源码
def empty(shape, ctx=cpu(0)):
"""Create an empty array given shape and device
Parameters
----------
shape : tuple of int
The shape of the array
ctx : DLContext
The context of the array
Returns
-------
arr : ndarray
The array dlsys supported.
"""
shape = c_array(ctypes.c_int64, shape)
ndim = ctypes.c_int(len(shape))
handle = DLArrayHandle()
check_call(_LIB.DLArrayAlloc(
shape, ndim, ctx, ctypes.byref(handle)))
return NDArray(handle)
def hash(self, timestamp, latitude, longitude, altitude, authticket, sessiondata, requests):
self.location_hash = None
self.location_auth_hash = None
self.request_hashes = []
first_hash = self.hash32(authticket, seed=HASH_SEED)
location_bytes = d2h(latitude) + d2h(longitude) + d2h(altitude)
loc_hash = self.hash32(location_bytes, seed=first_hash)
self.location_auth_hash = ctypes.c_int32(loc_hash).value
loc_hash = self.hash32(location_bytes, seed=HASH_SEED)
self.location_hash = ctypes.c_int32(loc_hash).value
first_hash = self.hash64salt32(authticket, seed=HASH_SEED)
for request in requests:
req_hash = self.hash64salt64(request.SerializeToString(), seed=first_hash)
self.request_hashes.append(ctypes.c_int64(req_hash).value)
def generate_request_hash(authticket, request):
first_hash = hash64salt32(authticket, seed=HASH_SEED)
req_hash = hash64salt64(request, seed=first_hash)
return ctypes.c_int64(req_hash).value
def hash32(buf, seed):
buf = struct.pack(">I", seed) + buf
hash64 = calcHash(buf)
signedhash64 = ctypes.c_int64(hash64)
return ctypes.c_uint(signedhash64.value).value ^ ctypes.c_uint(signedhash64.value >> 32).value
def libvlc_clock():
'''Return the current time as defined by LibVLC. The unit is the microsecond.
Time increases monotonically (regardless of time zone changes and RTC
adjustements).
The origin is arbitrary but consistent across the whole system
(e.g. the system uptim, the time since the system was booted).
@note: On systems that support it, the POSIX monotonic clock is used.
'''
f = _Cfunctions.get('libvlc_clock', None) or \
_Cfunction('libvlc_clock', (), None,
ctypes.c_int64)
return f()
def libvlc_video_get_spu_delay(p_mi):
'''Get the current subtitle delay. Positive values means subtitles are being
displayed later, negative values earlier.
@param p_mi: media player.
@return: time (in microseconds) the display of subtitles is being delayed.
@version: LibVLC 2.0.0 or later.
'''
f = _Cfunctions.get('libvlc_video_get_spu_delay', None) or \
_Cfunction('libvlc_video_get_spu_delay', ((1,),), None,
ctypes.c_int64, MediaPlayer)
return f(p_mi)
def libvlc_video_set_spu_delay(p_mi, i_delay):
'''Set the subtitle delay. This affects the timing of when the subtitle will
be displayed. Positive values result in subtitles being displayed later,
while negative values will result in subtitles being displayed earlier.
The subtitle delay will be reset to zero each time the media changes.
@param p_mi: media player.
@param i_delay: time (in microseconds) the display of subtitles should be delayed.
@return: 0 on success, -1 on error.
@version: LibVLC 2.0.0 or later.
'''
f = _Cfunctions.get('libvlc_video_set_spu_delay', None) or \
_Cfunction('libvlc_video_set_spu_delay', ((1,), (1,),), None,
ctypes.c_int, MediaPlayer, ctypes.c_int64)
return f(p_mi, i_delay)
def libvlc_audio_get_delay(p_mi):
'''Get current audio delay.
@param p_mi: media player.
@return: the audio delay (microseconds).
@version: LibVLC 1.1.1 or later.
'''
f = _Cfunctions.get('libvlc_audio_get_delay', None) or \
_Cfunction('libvlc_audio_get_delay', ((1,),), None,
ctypes.c_int64, MediaPlayer)
return f(p_mi)
def libvlc_audio_set_delay(p_mi, i_delay):
'''Set current audio delay. The audio delay will be reset to zero each time the media changes.
@param p_mi: media player.
@param i_delay: the audio delay (microseconds).
@return: 0 on success, -1 on error.
@version: LibVLC 1.1.1 or later.
'''
f = _Cfunctions.get('libvlc_audio_set_delay', None) or \
_Cfunction('libvlc_audio_set_delay', ((1,), (1,),), None,
ctypes.c_int, MediaPlayer, ctypes.c_int64)
return f(p_mi, i_delay)
def _disk_c(self):
drive = unicode(os.getenv("SystemDrive"))
freeuser = ctypes.c_int64()
total = ctypes.c_int64()
free = ctypes.c_int64()
ctypes.windll.kernel32.GetDiskFreeSpaceExW(drive,
ctypes.byref(freeuser),
ctypes.byref(total),
ctypes.byref(free))
return freeuser.value
def libvlc_clock():
'''Return the current time as defined by LibVLC. The unit is the microsecond.
Time increases monotonically (regardless of time zone changes and RTC
adjustements).
The origin is arbitrary but consistent across the whole system
(e.g. the system uptim, the time since the system was booted).
@note: On systems that support it, the POSIX monotonic clock is used.
'''
f = _Cfunctions.get('libvlc_clock', None) or \
_Cfunction('libvlc_clock', (), None,
ctypes.c_int64)
return f()
def libvlc_video_get_spu_delay(p_mi):
'''Get the current subtitle delay. Positive values means subtitles are being
displayed later, negative values earlier.
@param p_mi: media player.
@return: time (in microseconds) the display of subtitles is being delayed.
@version: LibVLC 2.0.0 or later.
'''
f = _Cfunctions.get('libvlc_video_get_spu_delay', None) or \
_Cfunction('libvlc_video_get_spu_delay', ((1,),), None,
ctypes.c_int64, MediaPlayer)
return f(p_mi)
def libvlc_video_set_spu_delay(p_mi, i_delay):
'''Set the subtitle delay. This affects the timing of when the subtitle will
be displayed. Positive values result in subtitles being displayed later,
while negative values will result in subtitles being displayed earlier.
The subtitle delay will be reset to zero each time the media changes.
@param p_mi: media player.
@param i_delay: time (in microseconds) the display of subtitles should be delayed.
@return: 0 on success, -1 on error.
@version: LibVLC 2.0.0 or later.
'''
f = _Cfunctions.get('libvlc_video_set_spu_delay', None) or \
_Cfunction('libvlc_video_set_spu_delay', ((1,), (1,),), None,
ctypes.c_int, MediaPlayer, ctypes.c_int64)
return f(p_mi, i_delay)
def libvlc_audio_get_delay(p_mi):
'''Get current audio delay.
@param p_mi: media player.
@return: the audio delay (microseconds).
@version: LibVLC 1.1.1 or later.
'''
f = _Cfunctions.get('libvlc_audio_get_delay', None) or \
_Cfunction('libvlc_audio_get_delay', ((1,),), None,
ctypes.c_int64, MediaPlayer)
return f(p_mi)
def libvlc_audio_set_delay(p_mi, i_delay):
'''Set current audio delay. The audio delay will be reset to zero each time the media changes.
@param p_mi: media player.
@param i_delay: the audio delay (microseconds).
@return: 0 on success, -1 on error.
@version: LibVLC 1.1.1 or later.
'''
f = _Cfunctions.get('libvlc_audio_set_delay', None) or \
_Cfunction('libvlc_audio_set_delay', ((1,), (1,),), None,
ctypes.c_int, MediaPlayer, ctypes.c_int64)
return f(p_mi, i_delay)
def libvlc_clock():
'''Return the current time as defined by LibVLC. The unit is the microsecond.
Time increases monotonically (regardless of time zone changes and RTC
adjustements).
The origin is arbitrary but consistent across the whole system
(e.g. the system uptim, the time since the system was booted).
@note: On systems that support it, the POSIX monotonic clock is used.
'''
f = _Cfunctions.get('libvlc_clock', None) or \
_Cfunction('libvlc_clock', (), None,
ctypes.c_int64)
return f()
def libvlc_video_get_spu_delay(p_mi):
'''Get the current subtitle delay. Positive values means subtitles are being
displayed later, negative values earlier.
@param p_mi: media player.
@return: time (in microseconds) the display of subtitles is being delayed.
@version: LibVLC 2.0.0 or later.
'''
f = _Cfunctions.get('libvlc_video_get_spu_delay', None) or \
_Cfunction('libvlc_video_get_spu_delay', ((1,),), None,
ctypes.c_int64, MediaPlayer)
return f(p_mi)
def libvlc_video_set_spu_delay(p_mi, i_delay):
'''Set the subtitle delay. This affects the timing of when the subtitle will
be displayed. Positive values result in subtitles being displayed later,
while negative values will result in subtitles being displayed earlier.
The subtitle delay will be reset to zero each time the media changes.
@param p_mi: media player.
@param i_delay: time (in microseconds) the display of subtitles should be delayed.
@return: 0 on success, -1 on error.
@version: LibVLC 2.0.0 or later.
'''
f = _Cfunctions.get('libvlc_video_set_spu_delay', None) or \
_Cfunction('libvlc_video_set_spu_delay', ((1,), (1,),), None,
ctypes.c_int, MediaPlayer, ctypes.c_int64)
return f(p_mi, i_delay)
def libvlc_audio_get_delay(p_mi):
'''Get current audio delay.
@param p_mi: media player.
@return: the audio delay (microseconds).
@version: LibVLC 1.1.1 or later.
'''
f = _Cfunctions.get('libvlc_audio_get_delay', None) or \
_Cfunction('libvlc_audio_get_delay', ((1,),), None,
ctypes.c_int64, MediaPlayer)
return f(p_mi)
def libvlc_audio_set_delay(p_mi, i_delay):
'''Set current audio delay. The audio delay will be reset to zero each time the media changes.
@param p_mi: media player.
@param i_delay: the audio delay (microseconds).
@return: 0 on success, -1 on error.
@version: LibVLC 1.1.1 or later.
'''
f = _Cfunctions.get('libvlc_audio_set_delay', None) or \
_Cfunction('libvlc_audio_set_delay', ((1,), (1,),), None,
ctypes.c_int, MediaPlayer, ctypes.c_int64)
return f(p_mi, i_delay)
def libvlc_clock():
'''Return the current time as defined by LibVLC. The unit is the microsecond.
Time increases monotonically (regardless of time zone changes and RTC
adjustements).
The origin is arbitrary but consistent across the whole system
(e.g. the system uptim, the time since the system was booted).
@note: On systems that support it, the POSIX monotonic clock is used.
'''
f = _Cfunctions.get('libvlc_clock', None) or \
_Cfunction('libvlc_clock', (), None,
ctypes.c_int64)
return f()
def libvlc_video_get_spu_delay(p_mi):
'''Get the current subtitle delay. Positive values means subtitles are being
displayed later, negative values earlier.
@param p_mi: media player.
@return: time (in microseconds) the display of subtitles is being delayed.
@version: LibVLC 2.0.0 or later.
'''
f = _Cfunctions.get('libvlc_video_get_spu_delay', None) or \
_Cfunction('libvlc_video_get_spu_delay', ((1,),), None,
ctypes.c_int64, MediaPlayer)
return f(p_mi)
def libvlc_video_set_spu_delay(p_mi, i_delay):
'''Set the subtitle delay. This affects the timing of when the subtitle will
be displayed. Positive values result in subtitles being displayed later,
while negative values will result in subtitles being displayed earlier.
The subtitle delay will be reset to zero each time the media changes.
@param p_mi: media player.
@param i_delay: time (in microseconds) the display of subtitles should be delayed.
@return: 0 on success, -1 on error.
@version: LibVLC 2.0.0 or later.
'''
f = _Cfunctions.get('libvlc_video_set_spu_delay', None) or \
_Cfunction('libvlc_video_set_spu_delay', ((1,), (1,),), None,
ctypes.c_int, MediaPlayer, ctypes.c_int64)
return f(p_mi, i_delay)
def libvlc_audio_get_delay(p_mi):
'''Get current audio delay.
@param p_mi: media player.
@return: the audio delay (microseconds).
@version: LibVLC 1.1.1 or later.
'''
f = _Cfunctions.get('libvlc_audio_get_delay', None) or \
_Cfunction('libvlc_audio_get_delay', ((1,),), None,
ctypes.c_int64, MediaPlayer)
return f(p_mi)
def libvlc_audio_set_delay(p_mi, i_delay):
'''Set current audio delay. The audio delay will be reset to zero each time the media changes.
@param p_mi: media player.
@param i_delay: the audio delay (microseconds).
@return: 0 on success, -1 on error.
@version: LibVLC 1.1.1 or later.
'''
f = _Cfunctions.get('libvlc_audio_set_delay', None) or \
_Cfunction('libvlc_audio_set_delay', ((1,), (1,),), None,
ctypes.c_int, MediaPlayer, ctypes.c_int64)
return f(p_mi, i_delay)
def libvlc_clock():
'''Return the current time as defined by LibVLC. The unit is the microsecond.
Time increases monotonically (regardless of time zone changes and RTC
adjustements).
The origin is arbitrary but consistent across the whole system
(e.g. the system uptim, the time since the system was booted).
@note: On systems that support it, the POSIX monotonic clock is used.
'''
f = _Cfunctions.get('libvlc_clock', None) or \
_Cfunction('libvlc_clock', (), None,
ctypes.c_int64)
return f()
def libvlc_video_get_spu_delay(p_mi):
'''Get the current subtitle delay. Positive values means subtitles are being
displayed later, negative values earlier.
@param p_mi: media player.
@return: time (in microseconds) the display of subtitles is being delayed.
@version: LibVLC 2.0.0 or later.
'''
f = _Cfunctions.get('libvlc_video_get_spu_delay', None) or \
_Cfunction('libvlc_video_get_spu_delay', ((1,),), None,
ctypes.c_int64, MediaPlayer)
return f(p_mi)
def libvlc_video_set_spu_delay(p_mi, i_delay):
'''Set the subtitle delay. This affects the timing of when the subtitle will
be displayed. Positive values result in subtitles being displayed later,
while negative values will result in subtitles being displayed earlier.
The subtitle delay will be reset to zero each time the media changes.
@param p_mi: media player.
@param i_delay: time (in microseconds) the display of subtitles should be delayed.
@return: 0 on success, -1 on error.
@version: LibVLC 2.0.0 or later.
'''
f = _Cfunctions.get('libvlc_video_set_spu_delay', None) or \
_Cfunction('libvlc_video_set_spu_delay', ((1,), (1,),), None,
ctypes.c_int, MediaPlayer, ctypes.c_int64)
return f(p_mi, i_delay)
def libvlc_audio_get_delay(p_mi):
'''Get current audio delay.
@param p_mi: media player.
@return: the audio delay (microseconds).
@version: LibVLC 1.1.1 or later.
'''
f = _Cfunctions.get('libvlc_audio_get_delay', None) or \
_Cfunction('libvlc_audio_get_delay', ((1,),), None,
ctypes.c_int64, MediaPlayer)
return f(p_mi)