package com.google.android.gms.internal.ads;

import androidx.annotation.Nullable;
import androidx.media3.common.MimeTypes;
import java.io.IOException;
import java.io.StringReader;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import org.xmlpull.v1.XmlPullParserFactory;

/* JADX INFO: loaded from: classes2.dex */
public abstract class w4 {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public static final String[] f17858a = {"Camera:MotionPhoto", "GCamera:MotionPhoto", "Camera:MicroVideo", "GCamera:MicroVideo"};

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public static final String[] f17859b = {"Camera:MotionPhotoPresentationTimestampUs", "GCamera:MotionPhotoPresentationTimestampUs", "Camera:MicroVideoPresentationTimestampUs", "GCamera:MicroVideoPresentationTimestampUs"};

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public static final String[] f17860c = {"Camera:MicroVideoOffset", "GCamera:MicroVideoOffset"};

    public static zzguf a(XmlPullParser xmlPullParser, String str, String str2) throws XmlPullParserException, IOException {
        bs1 bs1Var = zzguf.f19771b;
        as1 as1Var = new as1(4);
        do {
            String strConcat = str.concat(":Item");
            xmlPullParser.next();
            if (ke1.b(xmlPullParser, strConcat)) {
                String strConcat2 = str2.concat(":Mime");
                String strConcat3 = str2.concat(":Semantic");
                String strConcat4 = str2.concat(":Length");
                String strConcat5 = str2.concat(":Padding");
                String strZzc = ke1.zzc(xmlPullParser, strConcat2);
                String strZzc2 = ke1.zzc(xmlPullParser, strConcat3);
                String strZzc3 = ke1.zzc(xmlPullParser, strConcat4);
                String strZzc4 = ke1.zzc(xmlPullParser, strConcat5);
                if (strZzc == null || strZzc2 == null) {
                    return zzgwa.f19786e;
                }
                as1Var.a(new u4(strZzc, strZzc3 != null ? Long.parseLong(strZzc3) : 0L, strZzc4 != null ? Long.parseLong(strZzc4) : 0L));
            }
        } while (!ke1.a(xmlPullParser, str.concat(":Directory")));
        return as1Var.g();
    }

    /* JADX WARN: Code restructure failed: missing block: B:27:0x0084, code lost:
    
        r7 = -9223372036854775807L;
     */
    @Nullable
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public static v4 zza(String str) throws IOException {
        long j10;
        try {
            XmlPullParser xmlPullParserNewPullParser = XmlPullParserFactory.newInstance().newPullParser();
            xmlPullParserNewPullParser.setInput(new StringReader(str));
            xmlPullParserNewPullParser.next();
            if (!ke1.b(xmlPullParserNewPullParser, "x:xmpmeta")) {
                throw zzat.zzb("Couldn't find xmp metadata", null);
            }
            bs1 bs1Var = zzguf.f19771b;
            zzguf zzgufVarP = zzgwa.f19786e;
            long j11 = -9223372036854775807L;
            do {
                xmlPullParserNewPullParser.next();
                if (ke1.b(xmlPullParserNewPullParser, "rdf:Description")) {
                    String[] strArr = f17858a;
                    int i10 = 0;
                    for (int i11 = 0; i11 < 4; i11++) {
                        String strZzc = ke1.zzc(xmlPullParserNewPullParser, strArr[i11]);
                        if (strZzc != null) {
                            if (Integer.parseInt(strZzc) != 1) {
                                return null;
                            }
                            String[] strArr2 = f17859b;
                            int i12 = 0;
                            while (true) {
                                if (i12 >= 4) {
                                    break;
                                }
                                String strZzc2 = ke1.zzc(xmlPullParserNewPullParser, strArr2[i12]);
                                if (strZzc2 != null) {
                                    j10 = Long.parseLong(strZzc2);
                                    if (j10 == -1) {
                                        break;
                                    }
                                } else {
                                    i12++;
                                }
                            }
                            String[] strArr3 = f17860c;
                            while (true) {
                                if (i10 >= 2) {
                                    zzgufVarP = zzgwa.f19786e;
                                    break;
                                }
                                String strZzc3 = ke1.zzc(xmlPullParserNewPullParser, strArr3[i10]);
                                if (strZzc3 != null) {
                                    zzgufVarP = zzguf.p(new u4(MimeTypes.IMAGE_JPEG, 0L, 0L), new u4(MimeTypes.VIDEO_MP4, Long.parseLong(strZzc3), 0L));
                                    break;
                                }
                                i10++;
                            }
                            j11 = j10;
                        }
                    }
                    return null;
                }
                if (ke1.b(xmlPullParserNewPullParser, "Container:Directory")) {
                    zzgufVarP = a(xmlPullParserNewPullParser, "Container", "Item");
                } else if (ke1.b(xmlPullParserNewPullParser, "GContainer:Directory")) {
                    zzgufVarP = a(xmlPullParserNewPullParser, "GContainer", "GContainerItem");
                }
            } while (!ke1.a(xmlPullParserNewPullParser, "x:xmpmeta"));
            if (zzgufVarP.isEmpty()) {
                return null;
            }
            return new v4(j11, zzgufVarP);
        } catch (zzat | NumberFormatException | XmlPullParserException unused) {
            vt0.c("Ignoring unexpected XMP metadata");
            return null;
        }
    }

    public static boolean zzb(@Nullable String str) {
        if (str == null) {
            return false;
        }
        String[] strArr = f17858a;
        for (int i10 = 0; i10 < 4; i10++) {
            if (str.contains(String.valueOf(strArr[i10]).concat("=\"1\""))) {
                return true;
            }
        }
        return false;
    }
}
