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 
25 namespace android {
26 
27 struct HTTPBase;
28 struct MediaHTTPService;
29 
30 struct SDPLoader : public AHandler {
31     enum Flags {
32         // Don't log any URLs.
33         kFlagIncognito = 1,
34     };
35     enum {
36         kWhatSDPLoaded = 'sdpl'
37     };
38     SDPLoader(
39             const sp<AMessage> &notify,
40             uint32_t flags,
41             const sp<MediaHTTPService> &httpService);
42 
43     void load(const char* url, const KeyedVector<String8, String8> *headers);
44 
45     void cancel();
46 
47 protected:
~SDPLoaderSDPLoader48     virtual ~SDPLoader() {}
49 
50     virtual void onMessageReceived(const sp<AMessage> &msg);
51 
52 private:
53     enum {
54         kWhatLoad = 'load',
55     };
56 
57     void onLoad(const sp<AMessage> &msg);
58 
59     sp<AMessage> mNotify;
60     const char* mUrl;
61     uint32_t mFlags;
62     sp<ALooper> mNetLooper;
63     bool mCancelled;
64 
65     sp<HTTPBase> mHTTPDataSource;
66 
67     DISALLOW_EVIL_CONSTRUCTORS(SDPLoader);
68 };
69 
70 }  // namespace android
71 
72 #endif  // SDP_LOADER_H_
73