SDPLoader.h revision 7a33b7740412accf6a1cc912686c8d0acfb2a883
1/*
2 * Copyright (C) 2012 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef SDP_LOADER_H_
18
19#define SDP_LOADER_H_
20
21#include <media/stagefright/foundation/AMessage.h>
22#include <media/stagefright/foundation/AHandler.h>
23#include <utils/String8.h>
24
25namespace android {
26
27struct HTTPBase;
28
29struct SDPLoader : public AHandler {
30    enum Flags {
31        // Don't log any URLs.
32        kFlagIncognito = 1,
33    };
34    enum {
35        kWhatSDPLoaded = 'sdpl'
36    };
37    SDPLoader(const sp<AMessage> &notify, uint32_t flags = 0, bool uidValid = false, uid_t uid = 0);
38
39    void load(const char* url, const KeyedVector<String8, String8> *headers);
40
41    void cancel();
42
43protected:
44    virtual ~SDPLoader() {}
45
46    virtual void onMessageReceived(const sp<AMessage> &msg);
47
48private:
49    enum {
50        kWhatLoad = 'load',
51    };
52
53    void onLoad(const sp<AMessage> &msg);
54
55    sp<AMessage> mNotify;
56    const char* mUrl;
57    uint32_t mFlags;
58    bool mUIDValid;
59    uid_t mUID;
60    sp<ALooper> mNetLooper;
61    bool mCancelled;
62
63    sp<HTTPBase> mHTTPDataSource;
64
65    DISALLOW_EVIL_CONSTRUCTORS(SDPLoader);
66};
67
68}  // namespace android
69
70#endif  // SDP_LOADER_H_
71