In Av1 packetizer set marker bit with respect of end_of_picture flag

Bug: webrtc:12167
Change-Id: If14fdd7144951c7aa7e48efd390637dd66201bf7
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/192791
Reviewed-by: Erik Språng <sprang@webrtc.org>
Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#32612}
diff --git a/modules/rtp_rtcp/source/rtp_packetizer_av1.cc b/modules/rtp_rtcp/source/rtp_packetizer_av1.cc
index 909b128..4408bee 100644
--- a/modules/rtp_rtcp/source/rtp_packetizer_av1.cc
+++ b/modules/rtp_rtcp/source/rtp_packetizer_av1.cc
@@ -88,10 +88,12 @@
 
 RtpPacketizerAv1::RtpPacketizerAv1(rtc::ArrayView<const uint8_t> payload,
                                    RtpPacketizer::PayloadSizeLimits limits,
-                                   VideoFrameType frame_type)
+                                   VideoFrameType frame_type,
+                                   bool is_last_frame_in_picture)
     : frame_type_(frame_type),
       obus_(ParseObus(payload)),
-      packets_(Packetize(obus_, limits)) {}
+      packets_(Packetize(obus_, limits)),
+      is_last_frame_in_picture_(is_last_frame_in_picture) {}
 
 std::vector<RtpPacketizerAv1::Obu> RtpPacketizerAv1::ParseObus(
     rtc::ArrayView<const uint8_t> payload) {
@@ -414,11 +416,8 @@
                 kAggregationHeaderSize + next_packet.packet_size);
 
   ++packet_index_;
-  if (packet_index_ == packets_.size()) {
-    // TODO(danilchap): To support spatial scalability pass and use information
-    // if this frame is the last in the temporal unit.
-    packet->SetMarker(true);
-  }
+  bool is_last_packet_in_frame = packet_index_ == packets_.size();
+  packet->SetMarker(is_last_packet_in_frame && is_last_frame_in_picture_);
   return true;
 }