def create_stream(self, stream_class, id=None, name=None): utils._check_type(stream_class, bt2_stream_class._StreamClass) if stream_class.assigns_automatic_stream_id: if id is not None: raise ValueError( "id provided, but stream class assigns automatic stream ids" ) stream_ptr = native_bt.stream_create(stream_class._ptr, self._ptr) else: if id is None: raise ValueError( "id not provided, but stream class does not assign automatic stream ids" ) utils._check_uint64(id) stream_ptr = native_bt.stream_create_with_id( stream_class._ptr, self._ptr, id ) if stream_ptr is None: raise bt2._MemoryError('cannot create stream object') stream = bt2_stream._Stream._create_from_ptr(stream_ptr) if name is not None: stream._name = name return stream
def __call__(self, name=None, id=None): if name is not None: utils._check_str(name) if id is None: stream_ptr = native_bt.stream_create(self._ptr, name) else: stream_ptr = native_bt.stream_create_with_id(self._ptr, name, id) if stream_ptr is None: raise bt2.CreationError('cannot create stream object') return bt2.stream._create_from_ptr(stream_ptr)