(self, py_pkt)
| 127 | return result |
| 128 | |
| 129 | def python_packet_to_c_packet(self, py_pkt): |
| 130 | c_pkt = csdk.Packet() |
| 131 | c_pkt.set_timestamp(TimeStampType(py_pkt.get_timestamp())) |
| 132 | |
| 133 | # for EOF packet, ignore data |
| 134 | if py_pkt.get_timestamp() == Timestamp.EOF: |
| 135 | return c_pkt |
| 136 | |
| 137 | py_data = py_pkt.get_data() |
| 138 | |
| 139 | # TODO: support other type as dict and so on |
| 140 | if isinstance(py_data, VideoFrame): |
| 141 | c_frame = self.python_vframe_to_c_vframe(py_data) |
| 142 | c_pkt.py_set_data(c_frame) |
| 143 | return c_pkt |
| 144 | elif isinstance(py_data, AudioFrame): |
| 145 | c_frame = self.python_aframe_to_c_aframe(py_data) |
| 146 | c_pkt.py_set_data(c_frame) |
| 147 | return c_pkt |
| 148 | elif isinstance(py_data, numpy.ndarray): |
| 149 | c_pkt.py_set_data(py_data) |
| 150 | return c_pkt |
| 151 | else: |
| 152 | try: |
| 153 | c_frame = self.trans2dict(py_data) |
| 154 | except RuntimeError as e: |
| 155 | Log.log_node(LogLevel.ERROR, self.node_, e.args) |
| 156 | return None |
| 157 | c_pkt.py_set_data(c_frame) |
| 158 | return c_pkt |
| 159 | |
| 160 | def c_vframe_to_python_vframe(self, c_frame): |
| 161 | buf_pointers = [] |
no test coverage detected