| 420 | } |
| 421 | |
| 422 | void TsPacket::CreateAsPESFirst(TsPid pid, TsPESStreamId sid, |
| 423 | uint8_t continuity_counter, bool discontinuity, |
| 424 | int64_t pcr, int64_t dts, int64_t pts, int size) { |
| 425 | if (_modified) { |
| 426 | Reset(); |
| 427 | } |
| 428 | _pid = pid; |
| 429 | _payload_unit_start_indicator = 1; |
| 430 | _adaptation_field_control = TS_AF_PAYLOAD_ONLY; |
| 431 | _continuity_counter = continuity_counter; |
| 432 | TsPayloadPES* pes = new TsPayloadPES(this); |
| 433 | pes->stream_id = sid; |
| 434 | pes->PES_packet_length = (size > 0xFFFF ? 0 : size); |
| 435 | pes->PES_scrambling_control = 0; |
| 436 | pes->PES_priority = 0; |
| 437 | pes->data_alignment_indicator = 0; |
| 438 | pes->copyright = 0; |
| 439 | pes->original_or_copy = 0; |
| 440 | pes->PTS_DTS_flags = (dts == pts)? 0x02:0x03; |
| 441 | pes->ESCR_flag = 0; |
| 442 | pes->ES_rate_flag = 0; |
| 443 | pes->DSM_trick_mode_flag = 0; |
| 444 | pes->additional_copy_info_flag = 0; |
| 445 | pes->PES_CRC_flag = 0; |
| 446 | pes->PES_extension_flag = 0; |
| 447 | pes->pts = pts; |
| 448 | pes->dts = dts; |
| 449 | _payload = pes; |
| 450 | |
| 451 | if (pcr >= 0) { |
| 452 | TsAdaptationField* af = mutable_adaptation_field(); |
| 453 | af->discontinuity_indicator = discontinuity; |
| 454 | af->random_access_indicator = 0; |
| 455 | af->elementary_stream_priority_indicator = 0; |
| 456 | af->PCR_flag = 1; |
| 457 | af->OPCR_flag = 0; |
| 458 | af->splicing_point_flag = 0; |
| 459 | af->transport_private_data_flag = 0; |
| 460 | af->adaptation_field_extension_flag = 0; |
| 461 | af->program_clock_reference_base = pcr; |
| 462 | af->program_clock_reference_extension = 0; |
| 463 | } |
| 464 | } |
| 465 | |
| 466 | void TsPacket::CreateAsPESContinue(TsPid pid, uint8_t continuity_counter) { |
| 467 | if (_modified) { |