  
    // 1) Send video data at t=timestampEof/timestampSof
    // 2) Send encodeIndex packet at t=logMonoTime
    if (frame) {
      cereal::EncodeIndex::Reader idx;
      if (which == cereal::Event::ROAD_ENCODE_IDX) {
        idx = event.getRoadEncodeIdx();
      } else if (which == cereal::Event::DRIVER_ENCODE_IDX) {
        idx = event.getDriverEncodeIdx();
      } else if (which == cereal::Event::WIDE_ROAD_ENCODE_IDX) {
        idx = event.getWideRoadEncodeIdx();
      } else {
        assert(false);
      }
  
      // C2 only has eof set, and some older routes have neither
      uint64_t sof = idx.getTimestampSof();
      uint64_t eof = idx.getTimestampEof();
      if (sof > 0) {
        mono_time = sof;
 
</s> remove   if (e->which == cereal::Event::ROAD_ENCODE_IDX) {
    publish(RoadCam, e->event.getRoadEncodeIdx());
  } else if (e->which == cereal::Event::DRIVER_ENCODE_IDX) {
    publish(DriverCam, e->event.getDriverEncodeIdx());
  } else if (e->which == cereal::Event::WIDE_ROAD_ENCODE_IDX) {
    publish(WideRoadCam, e->event.getWideRoadEncodeIdx());
 </s> add   auto eidx = capnp::AnyStruct::Reader(e->event).getPointerSection()[0].getAs<cereal::EncodeIndex>();
  if (std::find(segments_merged_.begin(), segments_merged_.end(), eidx.getSegmentNum()) == segments_merged_.end()) {
    // eidx's segment is not loaded
    return;
  }
  CameraType cam = cam_types.at(e->which);
  auto &fr = segments_[eidx.getSegmentNum()]->frames[cam];
  if (fr && eidx.getType() == cereal::EncodeIndex::Type::FULL_H_E_V_C) {
    camera_server_->pushFrame(cam, fr.get(), eidx); </s> remove   auto publish = [=](CameraType cam_type, const cereal::EncodeIndex::Reader &eidx) {
    int n = eidx.getSegmentNum();
    bool segment_loaded = std::find(segments_merged_.begin(), segments_merged_.end(), n) != segments_merged_.end();
    if (segment_loaded && segments_[n]->frames[cam_type] && eidx.getType() == cereal::EncodeIndex::Type::FULL_H_E_V_C) {
      camera_server_->pushFrame(cam_type, segments_[n]->frames[cam_type].get(), eidx);
    }
 </s> add   static const std::map<cereal::Event::Which, CameraType> cam_types{
      {cereal::Event::ROAD_ENCODE_IDX, RoadCam},
      {cereal::Event::DRIVER_ENCODE_IDX, DriverCam},
      {cereal::Event::WIDE_ROAD_ENCODE_IDX, WideRoadCam},
    auto idx = capnp::AnyStruct::Reader(event).getPointerSection()[0].getAs<cereal::EncodeIndex>();
  
    // 1) Send video data at t=timestampEof/timestampSof
    // 2) Send encodeIndex packet at t=logMonoTime
    if (frame) {
    auto idx = capnp::AnyStruct::Reader(event).getPointerSection()[0].getAs<cereal::EncodeIndex>();
    auto idx = capnp::AnyStruct::Reader(event).getPointerSection()[0].getAs<cereal::EncodeIndex>();
    auto idx = capnp::AnyStruct::Reader(event).getPointerSection()[0].getAs<cereal::EncodeIndex>();
    auto idx = capnp::AnyStruct::Reader(event).getPointerSection()[0].getAs<cereal::EncodeIndex>();
    auto idx = capnp::AnyStruct::Reader(event).getPointerSection()[0].getAs<cereal::EncodeIndex>();
    auto idx = capnp::AnyStruct::Reader(event).getPointerSection()[0].getAs<cereal::EncodeIndex>();
    auto idx = capnp::AnyStruct::Reader(event).getPointerSection()[0].getAs<cereal::EncodeIndex>();
    auto idx = capnp::AnyStruct::Reader(event).getPointerSection()[0].getAs<cereal::EncodeIndex>();
    auto idx = capnp::AnyStruct::Reader(event).getPointerSection()[0].getAs<cereal::EncodeIndex>();
    auto idx = capnp::AnyStruct::Reader(event).getPointerSection()[0].getAs<cereal::EncodeIndex>();
    auto idx = capnp::AnyStruct::Reader(event).getPointerSection()[0].getAs<cereal::EncodeIndex>();
      // C2 only has eof set, and some older routes have neither
      uint64_t sof = idx.getTimestampSof();
      uint64_t eof = idx.getTimestampEof();
      if (sof > 0) {
        mono_time = sof;
keep keep keep keep replace replace replace replace replace replace replace replace replace replace replace keep keep keep keep keep
 replay: get EncoderIndex from capnp::AnyStruct (#22518)

* get EncoderIndex from capnp::AnyStruct

* const 
selfdrive/ui/replay/logreader.cc