| 172 | } |
| 173 | |
| 174 | static int chunk_end(AVFormatContext *s, int flush) |
| 175 | { |
| 176 | WebMChunkContext *wc = s->priv_data; |
| 177 | AVFormatContext *oc = wc->avf; |
| 178 | int ret; |
| 179 | int buffer_size; |
| 180 | uint8_t *buffer; |
| 181 | AVIOContext *pb; |
| 182 | AVBPrint filename; |
| 183 | AVDictionary *options = NULL; |
| 184 | |
| 185 | if (!oc->pb) |
| 186 | return 0; |
| 187 | |
| 188 | if (flush) |
| 189 | // Flush the cluster in WebM muxer. |
| 190 | av_write_frame(oc, NULL); |
| 191 | buffer_size = avio_close_dyn_buf(oc->pb, &buffer); |
| 192 | oc->pb = NULL; |
| 193 | av_bprint_init(&filename, 0, AV_BPRINT_SIZE_UNLIMITED); |
| 194 | ret = get_chunk_filename(s, &filename); |
| 195 | if (ret < 0) |
| 196 | goto fail; |
| 197 | if (wc->http_method) |
| 198 | if ((ret = av_dict_set(&options, "method", wc->http_method, 0)) < 0) |
| 199 | goto fail; |
| 200 | ret = s->io_open(s, &pb, filename.str, AVIO_FLAG_WRITE, &options); |
| 201 | av_dict_free(&options); |
| 202 | if (ret < 0) |
| 203 | goto fail; |
| 204 | avio_write(pb, buffer, buffer_size); |
| 205 | ff_format_io_close(s, &pb); |
| 206 | fail: |
| 207 | av_bprint_finalize(&filename, NULL); |
| 208 | av_free(buffer); |
| 209 | return (ret < 0) ? ret : 0; |
| 210 | } |
| 211 | |
| 212 | static int webm_chunk_write_packet(AVFormatContext *s, AVPacket *pkt) |
| 213 | { |
no test coverage detected