Search in sources :

Example 36 with UUID

use of java.util.UUID in project platform_frameworks_base by android.

the class MediaExtractor method getDrmInitData.

/**
     * Extract DRM initialization data if it exists
     *
     * @return DRM initialization data in the content, or {@code null}
     * if no recognizable DRM format is found;
     * @see DrmInitData
     */
public DrmInitData getDrmInitData() {
    Map<String, Object> formatMap = getFileFormatNative();
    if (formatMap == null) {
        return null;
    }
    if (formatMap.containsKey("pssh")) {
        Map<UUID, byte[]> psshMap = getPsshInfo();
        final Map<UUID, DrmInitData.SchemeInitData> initDataMap = new HashMap<UUID, DrmInitData.SchemeInitData>();
        for (Map.Entry<UUID, byte[]> e : psshMap.entrySet()) {
            UUID uuid = e.getKey();
            byte[] data = e.getValue();
            initDataMap.put(uuid, new DrmInitData.SchemeInitData("cenc", data));
        }
        return new DrmInitData() {

            public SchemeInitData get(UUID schemeUuid) {
                return initDataMap.get(schemeUuid);
            }
        };
    } else {
        int numTracks = getTrackCount();
        for (int i = 0; i < numTracks; ++i) {
            Map<String, Object> trackFormatMap = getTrackFormatNative(i);
            if (!trackFormatMap.containsKey("crypto-key")) {
                continue;
            }
            ByteBuffer buf = (ByteBuffer) trackFormatMap.get("crypto-key");
            buf.rewind();
            final byte[] data = new byte[buf.remaining()];
            buf.get(data);
            return new DrmInitData() {

                public SchemeInitData get(UUID schemeUuid) {
                    return new DrmInitData.SchemeInitData("webm", data);
                }
            };
        }
    }
    return null;
}
Also used : HashMap(java.util.HashMap) ByteBuffer(java.nio.ByteBuffer) UUID(java.util.UUID) HashMap(java.util.HashMap) Map(java.util.Map)

Example 37 with UUID

use of java.util.UUID in project platform_frameworks_base by android.

the class MediaExtractor method getPsshInfo.

/**
     * Get the PSSH info if present.
     * @return a map of uuid-to-bytes, with the uuid specifying
     * the crypto scheme, and the bytes being the data specific to that scheme.
     * This can be {@code null} if the source does not contain PSSH info.
     */
@Nullable
public Map<UUID, byte[]> getPsshInfo() {
    Map<UUID, byte[]> psshMap = null;
    Map<String, Object> formatMap = getFileFormatNative();
    if (formatMap != null && formatMap.containsKey("pssh")) {
        ByteBuffer rawpssh = (ByteBuffer) formatMap.get("pssh");
        rawpssh.order(ByteOrder.nativeOrder());
        rawpssh.rewind();
        formatMap.remove("pssh");
        // parse the flat pssh bytebuffer into something more manageable
        psshMap = new HashMap<UUID, byte[]>();
        while (rawpssh.remaining() > 0) {
            rawpssh.order(ByteOrder.BIG_ENDIAN);
            long msb = rawpssh.getLong();
            long lsb = rawpssh.getLong();
            UUID uuid = new UUID(msb, lsb);
            rawpssh.order(ByteOrder.nativeOrder());
            int datalen = rawpssh.getInt();
            byte[] psshdata = new byte[datalen];
            rawpssh.get(psshdata);
            psshMap.put(uuid, psshdata);
        }
    }
    return psshMap;
}
Also used : UUID(java.util.UUID) ByteBuffer(java.nio.ByteBuffer) Nullable(android.annotation.Nullable)

Example 38 with UUID

use of java.util.UUID in project androidquery by androidquery.

the class TestUtility method getDeviceId.

public static String getDeviceId(Context context) {
    if (deviceId == null) {
        TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
        String tmDevice, tmSerial, tmPhone, androidId;
        tmDevice = "" + tm.getDeviceId();
        tmSerial = "" + tm.getSimSerialNumber();
        androidId = "" + android.provider.Settings.Secure.getString(context.getContentResolver(), android.provider.Settings.Secure.ANDROID_ID);
        UUID deviceUuid = new UUID(androidId.hashCode(), ((long) tmDevice.hashCode() << 32) | tmSerial.hashCode());
        deviceId = deviceUuid.toString();
        System.err.println(deviceId);
    }
    return deviceId;
}
Also used : TelephonyManager(android.telephony.TelephonyManager) UUID(java.util.UUID)

Example 39 with UUID

use of java.util.UUID in project simplefacebook by androidquery.

the class PrefUtility method getDeviceId.

public static String getDeviceId() {
    if (deviceId == null) {
        Context context = MainApplication.getContext();
        TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
        String tmDevice, tmSerial, tmPhone, androidId;
        tmDevice = "" + tm.getDeviceId();
        tmSerial = "" + tm.getSimSerialNumber();
        androidId = "" + android.provider.Settings.Secure.getString(context.getContentResolver(), android.provider.Settings.Secure.ANDROID_ID);
        UUID deviceUuid = new UUID(androidId.hashCode(), ((long) tmDevice.hashCode() << 32) | tmSerial.hashCode());
        deviceId = deviceUuid.toString();
    }
    System.err.println("device:" + deviceId);
    return deviceId;
}
Also used : Context(android.content.Context) TelephonyManager(android.telephony.TelephonyManager) UUID(java.util.UUID)

Example 40 with UUID

use of java.util.UUID in project antlr4 by antlr.

the class ATNSerializer method decode.

public String decode(char[] data) {
    data = data.clone();
    // don't adjust the first value since that's the version number
    for (int i = 1; i < data.length; i++) {
        data[i] = (char) (data[i] - 2);
    }
    StringBuilder buf = new StringBuilder();
    int p = 0;
    int version = ATNDeserializer.toInt(data[p++]);
    if (version != ATNDeserializer.SERIALIZED_VERSION) {
        String reason = String.format("Could not deserialize ATN with version %d (expected %d).", version, ATNDeserializer.SERIALIZED_VERSION);
        throw new UnsupportedOperationException(new InvalidClassException(ATN.class.getName(), reason));
    }
    UUID uuid = ATNDeserializer.toUUID(data, p);
    p += 8;
    if (!uuid.equals(ATNDeserializer.SERIALIZED_UUID)) {
        String reason = String.format(Locale.getDefault(), "Could not deserialize ATN with UUID %s (expected %s).", uuid, ATNDeserializer.SERIALIZED_UUID);
        throw new UnsupportedOperationException(new InvalidClassException(ATN.class.getName(), reason));
    }
    // skip grammarType
    p++;
    int maxType = ATNDeserializer.toInt(data[p++]);
    buf.append("max type ").append(maxType).append("\n");
    int nstates = ATNDeserializer.toInt(data[p++]);
    for (int i = 0; i < nstates; i++) {
        int stype = ATNDeserializer.toInt(data[p++]);
        // ignore bad type of states
        if (stype == ATNState.INVALID_TYPE)
            continue;
        int ruleIndex = ATNDeserializer.toInt(data[p++]);
        if (ruleIndex == Character.MAX_VALUE) {
            ruleIndex = -1;
        }
        String arg = "";
        if (stype == ATNState.LOOP_END) {
            int loopBackStateNumber = ATNDeserializer.toInt(data[p++]);
            arg = " " + loopBackStateNumber;
        } else if (stype == ATNState.PLUS_BLOCK_START || stype == ATNState.STAR_BLOCK_START || stype == ATNState.BLOCK_START) {
            int endStateNumber = ATNDeserializer.toInt(data[p++]);
            arg = " " + endStateNumber;
        }
        buf.append(i).append(":").append(ATNState.serializationNames.get(stype)).append(" ").append(ruleIndex).append(arg).append("\n");
    }
    // this code is meant to model the form of ATNDeserializer.deserialize,
    // since both need to be updated together whenever a change is made to
    // the serialization format. The "dead" code is only used in debugging
    // and testing scenarios, so the form you see here was kept for
    // improved maintainability.
    // start
    int numNonGreedyStates = ATNDeserializer.toInt(data[p++]);
    for (int i = 0; i < numNonGreedyStates; i++) {
        int stateNumber = ATNDeserializer.toInt(data[p++]);
    }
    int numPrecedenceStates = ATNDeserializer.toInt(data[p++]);
    for (int i = 0; i < numPrecedenceStates; i++) {
        int stateNumber = ATNDeserializer.toInt(data[p++]);
    }
    // finish
    int nrules = ATNDeserializer.toInt(data[p++]);
    for (int i = 0; i < nrules; i++) {
        int s = ATNDeserializer.toInt(data[p++]);
        if (atn.grammarType == ATNType.LEXER) {
            int arg1 = ATNDeserializer.toInt(data[p++]);
            buf.append("rule ").append(i).append(":").append(s).append(" ").append(arg1).append('\n');
        } else {
            buf.append("rule ").append(i).append(":").append(s).append('\n');
        }
    }
    int nmodes = ATNDeserializer.toInt(data[p++]);
    for (int i = 0; i < nmodes; i++) {
        int s = ATNDeserializer.toInt(data[p++]);
        buf.append("mode ").append(i).append(":").append(s).append('\n');
    }
    int numBMPSets = ATNDeserializer.toInt(data[p++]);
    p = appendSets(buf, data, p, numBMPSets, 0, ATNDeserializer.getUnicodeDeserializer(ATNDeserializer.UnicodeDeserializingMode.UNICODE_BMP));
    int numSMPSets = ATNDeserializer.toInt(data[p++]);
    p = appendSets(buf, data, p, numSMPSets, numBMPSets, ATNDeserializer.getUnicodeDeserializer(ATNDeserializer.UnicodeDeserializingMode.UNICODE_SMP));
    int nedges = ATNDeserializer.toInt(data[p++]);
    for (int i = 0; i < nedges; i++) {
        int src = ATNDeserializer.toInt(data[p]);
        int trg = ATNDeserializer.toInt(data[p + 1]);
        int ttype = ATNDeserializer.toInt(data[p + 2]);
        int arg1 = ATNDeserializer.toInt(data[p + 3]);
        int arg2 = ATNDeserializer.toInt(data[p + 4]);
        int arg3 = ATNDeserializer.toInt(data[p + 5]);
        buf.append(src).append("->").append(trg).append(" ").append(Transition.serializationNames.get(ttype)).append(" ").append(arg1).append(",").append(arg2).append(",").append(arg3).append("\n");
        p += 6;
    }
    int ndecisions = ATNDeserializer.toInt(data[p++]);
    for (int i = 0; i < ndecisions; i++) {
        int s = ATNDeserializer.toInt(data[p++]);
        buf.append(i).append(":").append(s).append("\n");
    }
    if (atn.grammarType == ATNType.LEXER) {
        // this code is meant to model the form of ATNDeserializer.deserialize,
        // since both need to be updated together whenever a change is made to
        // the serialization format. The "dead" code is only used in debugging
        // and testing scenarios, so the form you see here was kept for
        // improved maintainability.
        int lexerActionCount = ATNDeserializer.toInt(data[p++]);
        for (int i = 0; i < lexerActionCount; i++) {
            LexerActionType actionType = LexerActionType.values()[ATNDeserializer.toInt(data[p++])];
            int data1 = ATNDeserializer.toInt(data[p++]);
            int data2 = ATNDeserializer.toInt(data[p++]);
        }
    }
    return buf.toString();
}
Also used : InvalidClassException(java.io.InvalidClassException) UUID(java.util.UUID)

Aggregations

UUID (java.util.UUID)2848 Test (org.junit.Test)641 ArrayList (java.util.ArrayList)337 Test (org.testng.annotations.Test)308 HashMap (java.util.HashMap)306 Map (java.util.Map)201 ClusterNode (org.apache.ignite.cluster.ClusterNode)182 List (java.util.List)163 BigDecimal (java.math.BigDecimal)148 LocalDate (org.joda.time.LocalDate)145 Ignite (org.apache.ignite.Ignite)131 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)118 DateTime (org.joda.time.DateTime)109 HashSet (java.util.HashSet)107 Invoice (org.killbill.billing.invoice.api.Invoice)105 CountDownLatch (java.util.concurrent.CountDownLatch)101 IOException (java.io.IOException)92 ByteBuffer (java.nio.ByteBuffer)81 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)75 File (java.io.File)73