| 119 | } |
| 120 | |
| 121 | void VTRgbPacketProcessor::process(const RgbPacket &packet) |
| 122 | { |
| 123 | if (listener_ != 0) { |
| 124 | impl_->startTiming(); |
| 125 | |
| 126 | CMBlockBufferRef blockBuffer; |
| 127 | CMBlockBufferCreateWithMemoryBlock( |
| 128 | NULL, |
| 129 | packet.jpeg_buffer, |
| 130 | packet.jpeg_buffer_length, |
| 131 | kCFAllocatorNull, |
| 132 | NULL, |
| 133 | 0, |
| 134 | packet.jpeg_buffer_length, |
| 135 | 0, |
| 136 | &blockBuffer |
| 137 | ); |
| 138 | |
| 139 | CMSampleBufferRef sampleBuffer; |
| 140 | CMSampleBufferCreate( |
| 141 | NULL, |
| 142 | blockBuffer, |
| 143 | true, |
| 144 | NULL, |
| 145 | NULL, |
| 146 | impl_->format, |
| 147 | 1, |
| 148 | 0, |
| 149 | NULL, |
| 150 | 0, |
| 151 | NULL, |
| 152 | &sampleBuffer |
| 153 | ); |
| 154 | |
| 155 | CVPixelBufferRef pixelBuffer = NULL; |
| 156 | VTDecompressionSessionDecodeFrame(impl_->decoder, sampleBuffer, 0, &pixelBuffer, NULL); |
| 157 | |
| 158 | Frame *frame = new VTFrame(1920, 1080, 4, pixelBuffer); |
| 159 | frame->format = Frame::BGRX; |
| 160 | |
| 161 | frame->timestamp = packet.timestamp; |
| 162 | frame->sequence = packet.sequence; |
| 163 | frame->exposure = packet.exposure; |
| 164 | frame->gain = packet.gain; |
| 165 | frame->gamma = packet.gamma; |
| 166 | |
| 167 | if (!listener_->onNewFrame(Frame::Color, frame)) { |
| 168 | // The listener didn't take ownership of the frame, so we delete it |
| 169 | delete frame; |
| 170 | } |
| 171 | |
| 172 | CFRelease(sampleBuffer); |
| 173 | CFRelease(blockBuffer); |
| 174 | |
| 175 | impl_->stopTiming(LOG_INFO); |
| 176 | } |
| 177 | } |
| 178 |
nothing calls this directly
no test coverage detected