DXR is a code search and navigation tool aimed at making sense of large projects. It supports full-text and regex searches as well as structural queries.

Mercurial (d1ed7de67f5a)

VCS Links

Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296
diff --git a/GonkCameraListener.h b/GonkCameraListener.h
index 67eeef3..243264c 100644
--- a/GonkCameraListener.h
+++ b/GonkCameraListener.h
@@ -14,49 +14,16 @@
  * limitations under the License.
  */
 
-#ifndef ANDROID_HARDWARE_CAMERA_H
-#define ANDROID_HARDWARE_CAMERA_H
+#ifndef GONK_CAMERA_LISTENER_H
+#define GONK_CAMERA_LISTENER_H
 
 #include <utils/Timers.h>
-#include <gui/ISurfaceTexture.h>
-#include <system/camera.h>
-#include <camera/ICameraClient.h>
-#include <camera/ICameraRecordingProxy.h>
-#include <camera/ICameraRecordingProxyListener.h>
+#include "libcameraservice/CameraHardwareInterface.h"
 
 namespace android {
 
-struct CameraInfo {
-    /**
-     * The direction that the camera faces to. It should be CAMERA_FACING_BACK
-     * or CAMERA_FACING_FRONT.
-     */
-    int facing;
-
-    /**
-     * The orientation of the camera image. The value is the angle that the
-     * camera image needs to be rotated clockwise so it shows correctly on the
-     * display in its natural orientation. It should be 0, 90, 180, or 270.
-     *
-     * For example, suppose a device has a naturally tall screen. The
-     * back-facing camera sensor is mounted in landscape. You are looking at
-     * the screen. If the top side of the camera sensor is aligned with the
-     * right edge of the screen in natural orientation, the value should be
-     * 90. If the top side of a front-facing camera sensor is aligned with the
-     * right of the screen, the value should be 270.
-     */
-    int orientation;
-    int mode;
-};
-
-class ICameraService;
-class ICamera;
-class Surface;
-class Mutex;
-class String8;
-
 // ref-counted object for callbacks
-class CameraListener: virtual public RefBase
+class GonkCameraListener: virtual public RefBase
 {
 public:
     virtual void notify(int32_t msgType, int32_t ext1, int32_t ext2) = 0;
@@ -65,133 +32,6 @@ public:
     virtual void postDataTimestamp(nsecs_t timestamp, int32_t msgType, const sp<IMemory>& dataPtr) = 0;
 };
 
-class Camera : public BnCameraClient, public IBinder::DeathRecipient
-{
-public:
-            // construct a camera client from an existing remote
-    static  sp<Camera>  create(const sp<ICamera>& camera);
-    static  int32_t     getNumberOfCameras();
-    static  status_t    getCameraInfo(int cameraId,
-                                      struct CameraInfo* cameraInfo);
-    static  sp<Camera>  connect(int cameraId);
-            virtual     ~Camera();
-            void        init();
-
-            status_t    reconnect();
-            void        disconnect();
-            status_t    lock();
-            status_t    unlock();
-
-            status_t    getStatus() { return mStatus; }
-
-            // pass the buffered Surface to the camera service
-            status_t    setPreviewDisplay(const sp<Surface>& surface);
-
-            // pass the buffered ISurfaceTexture to the camera service
-            status_t    setPreviewTexture(const sp<ISurfaceTexture>& surfaceTexture);
-
-            // start preview mode, must call setPreviewDisplay first
-            status_t    startPreview();
-
-            // stop preview mode
-            void        stopPreview();
-
-            // get preview state
-            bool        previewEnabled();
-
-            // start recording mode, must call setPreviewDisplay first
-            status_t    startRecording();
-
-            // stop recording mode
-            void        stopRecording();
-
-            // get recording state
-            bool        recordingEnabled();
-
-            // release a recording frame
-            void        releaseRecordingFrame(const sp<IMemory>& mem);
-
-            // autoFocus - status returned from callback
-            status_t    autoFocus();
-
-            // cancel auto focus
-            status_t    cancelAutoFocus();
-
-            // take a picture - picture returned from callback
-            status_t    takePicture(int msgType);
-
-            // set preview/capture parameters - key/value pairs
-            status_t    setParameters(const String8& params);
-
-            // get preview/capture parameters - key/value pairs
-            String8     getParameters() const;
-
-            // send command to camera driver
-            status_t    sendCommand(int32_t cmd, int32_t arg1, int32_t arg2);
-
-            // tell camera hal to store meta data or real YUV in video buffers.
-            status_t    storeMetaDataInBuffers(bool enabled);
-
-            void        setListener(const sp<CameraListener>& listener);
-            void        setRecordingProxyListener(const sp<ICameraRecordingProxyListener>& listener);
-            void        setPreviewCallbackFlags(int preview_callback_flag);
-
-            sp<ICameraRecordingProxy> getRecordingProxy();
-
-    // ICameraClient interface
-    virtual void        notifyCallback(int32_t msgType, int32_t ext, int32_t ext2);
-    virtual void        dataCallback(int32_t msgType, const sp<IMemory>& dataPtr,
-                                     camera_frame_metadata_t *metadata);
-    virtual void        dataCallbackTimestamp(nsecs_t timestamp, int32_t msgType, const sp<IMemory>& dataPtr);
-
-    sp<ICamera>         remote();
-
-    class RecordingProxy : public BnCameraRecordingProxy
-    {
-    public:
-        RecordingProxy(const sp<Camera>& camera);
-
-        // ICameraRecordingProxy interface
-        virtual status_t startRecording(const sp<ICameraRecordingProxyListener>& listener);
-        virtual void stopRecording();
-        virtual void releaseRecordingFrame(const sp<IMemory>& mem);
-
-    private:
-        sp<Camera>         mCamera;
-    };
-
-private:
-                        Camera();
-                        Camera(const Camera&);
-                        Camera& operator=(const Camera);
-                        virtual void binderDied(const wp<IBinder>& who);
-
-            class DeathNotifier: public IBinder::DeathRecipient
-            {
-            public:
-                DeathNotifier() {
-                }
-
-                virtual void binderDied(const wp<IBinder>& who);
-            };
-
-            static sp<DeathNotifier> mDeathNotifier;
-
-            // helper function to obtain camera service handle
-            static const sp<ICameraService>& getCameraService();
-
-            sp<ICamera>         mCamera;
-            status_t            mStatus;
-
-            sp<CameraListener>  mListener;
-            sp<ICameraRecordingProxyListener>  mRecordingProxyListener;
-
-            friend class DeathNotifier;
-
-            static  Mutex               mLock;
-            static  sp<ICameraService>  mCameraService;
-};
-
 }; // namespace android
 
 #endif
diff --git a/GonkCameraSource.cpp b/GonkCameraSource.cpp
index af6b340..9dba596 100644
--- a/GonkCameraSource.cpp
+++ b/GonkCameraSource.cpp
@@ -14,29 +14,34 @@
  * limitations under the License.
  */
 
-//#define LOG_NDEBUG 0
-#define LOG_TAG "CameraSource"
-#include <utils/Log.h>
+#include <base/basictypes.h>
+#include "nsDebug.h"
+#define DOM_CAMERA_LOG_LEVEL        3
+#include "CameraCommon.h"
+#define LOGD DOM_CAMERA_LOGA
+#define LOGV DOM_CAMERA_LOGI
+#define LOGI DOM_CAMERA_LOGI
+#define LOGW DOM_CAMERA_LOGW
+#define LOGE DOM_CAMERA_LOGE
 
 #include <OMX_Component.h>
-#include <binder/IPCThreadState.h>
-#include <media/stagefright/CameraSource.h>
+#include "GonkCameraSource.h"
+#include "GonkCameraListener.h"
+#include "GonkCameraHwMgr.h"
 #include <media/stagefright/MediaDebug.h>
 #include <media/stagefright/MediaDefs.h>
 #include <media/stagefright/MediaErrors.h>
 #include <media/stagefright/MetaData.h>
-#include <camera/Camera.h>
-#include <camera/CameraParameters.h>
-#include <surfaceflinger/Surface.h>
 #include <utils/String8.h>
 #include <cutils/properties.h>
 
+using namespace mozilla;
 namespace android {
 
 static const int64_t CAMERA_SOURCE_TIMEOUT_NS = 3000000000LL;
 
-struct CameraSourceListener : public CameraListener {
-    CameraSourceListener(const sp<CameraSource> &source);
+struct GonkCameraSourceListener : public GonkCameraListener {
+    GonkCameraSourceListener(const sp<GonkCameraSource> &source);
 
     virtual void notify(int32_t msgType, int32_t ext1, int32_t ext2);
     virtual void postData(int32_t msgType, const sp<IMemory> &dataPtr,
@@ -46,41 +51,41 @@ struct CameraSourceListener : public CameraListener {
             nsecs_t timestamp, int32_t msgType, const sp<IMemory>& dataPtr);
 
 protected:
-    virtual ~CameraSourceListener();
+    virtual ~GonkCameraSourceListener();
 
 private:
-    wp<CameraSource> mSource;
+    wp<GonkCameraSource> mSource;
 
-    CameraSourceListener(const CameraSourceListener &);
-    CameraSourceListener &operator=(const CameraSourceListener &);
+    GonkCameraSourceListener(const GonkCameraSourceListener &);
+    GonkCameraSourceListener &operator=(const GonkCameraSourceListener &);
 };
 
-CameraSourceListener::CameraSourceListener(const sp<CameraSource> &source)
+GonkCameraSourceListener::GonkCameraSourceListener(const sp<GonkCameraSource> &source)
     : mSource(source) {
 }
 
-CameraSourceListener::~CameraSourceListener() {
+GonkCameraSourceListener::~GonkCameraSourceListener() {
 }
 
-void CameraSourceListener::notify(int32_t msgType, int32_t ext1, int32_t ext2) {
+void GonkCameraSourceListener::notify(int32_t msgType, int32_t ext1, int32_t ext2) {
     LOGV("notify(%d, %d, %d)", msgType, ext1, ext2);
 }
 
-void CameraSourceListener::postData(int32_t msgType, const sp<IMemory> &dataPtr,
+void GonkCameraSourceListener::postData(int32_t msgType, const sp<IMemory> &dataPtr,
                                     camera_frame_metadata_t *metadata) {
     LOGV("postData(%d, ptr:%p, size:%d)",
          msgType, dataPtr->pointer(), dataPtr->size());
 
-    sp<CameraSource> source = mSource.promote();
+    sp<GonkCameraSource> source = mSource.promote();
     if (source.get() != NULL) {
         source->dataCallback(msgType, dataPtr);
     }
 }
 
-void CameraSourceListener::postDataTimestamp(
+void GonkCameraSourceListener::postDataTimestamp(
         nsecs_t timestamp, int32_t msgType, const sp<IMemory>& dataPtr) {
 
-    sp<CameraSource> source = mSource.promote();
+    sp<GonkCameraSource> source = mSource.promote();
     if (source.get() != NULL) {
         source->dataCallbackTimestamp(timestamp/1000, msgType, dataPtr);
     }
@@ -114,48 +119,30 @@ static int32_t getColorFormat(const char* colorFormat) {
     }
 
     LOGE("Uknown color format (%s), please add it to "
-         "CameraSource::getColorFormat", colorFormat);
+         "GonkCameraSource::getColorFormat", colorFormat);
 
     CHECK_EQ(0, "Unknown color format");
 }
 
-CameraSource *CameraSource::Create() {
-    Size size;
-    size.width = -1;
-    size.height = -1;
-
-    sp<ICamera> camera;
-    return new CameraSource(camera, NULL, 0, size, -1, NULL, false);
-}
-
-// static
-CameraSource *CameraSource::CreateFromCamera(
-    const sp<ICamera>& camera,
-    const sp<ICameraRecordingProxy>& proxy,
-    int32_t cameraId,
+GonkCameraSource *GonkCameraSource::Create(
+    int32_t cameraHandle,
     Size videoSize,
     int32_t frameRate,
-    const sp<Surface>& surface,
     bool storeMetaDataInVideoBuffers) {
 
-    CameraSource *source = new CameraSource(camera, proxy, cameraId,
-                    videoSize, frameRate, surface,
+    GonkCameraSource *source = new GonkCameraSource(cameraHandle,
+                    videoSize, frameRate,
                     storeMetaDataInVideoBuffers);
     return source;
 }
 
-CameraSource::CameraSource(
-    const sp<ICamera>& camera,
-    const sp<ICameraRecordingProxy>& proxy,
-    int32_t cameraId,
+GonkCameraSource::GonkCameraSource(
+    int32_t cameraHandle,
     Size videoSize,
     int32_t frameRate,
-    const sp<Surface>& surface,
     bool storeMetaDataInVideoBuffers)
     : mCameraFlags(0),
       mVideoFrameRate(-1),
-      mCamera(0),
-      mSurface(surface),
       mNumFramesReceived(0),
       mLastFrameTimestampUs(0),
       mStarted(false),
@@ -169,43 +156,19 @@ CameraSource::CameraSource(
     mVideoSize.width  = -1;
     mVideoSize.height = -1;
 
-    mInitCheck = init(camera, proxy, cameraId,
+    mCameraHandle = cameraHandle;
+
+    mInitCheck = init(
                     videoSize, frameRate,
                     storeMetaDataInVideoBuffers);
     if (mInitCheck != OK) releaseCamera();
 }
 
-status_t CameraSource::initCheck() const {
+status_t GonkCameraSource::initCheck() const {
     return mInitCheck;
 }
 
-status_t CameraSource::isCameraAvailable(
-    const sp<ICamera>& camera, const sp<ICameraRecordingProxy>& proxy,
-    int32_t cameraId) {
-
-    if (camera == 0) {
-        mCamera = Camera::connect(cameraId);
-        if (mCamera == 0) return -EBUSY;
-        mCameraFlags &= ~FLAGS_HOT_CAMERA;
-    } else {
-        // We get the proxy from Camera, not ICamera. We need to get the proxy
-        // to the remote Camera owned by the application. Here mCamera is a
-        // local Camera object created by us. We cannot use the proxy from
-        // mCamera here.
-        mCamera = Camera::create(camera);
-        if (mCamera == 0) return -EBUSY;
-        mCameraRecordingProxy = proxy;
-        mCameraFlags |= FLAGS_HOT_CAMERA;
-        mDeathNotifier = new DeathNotifier();
-        // isBinderAlive needs linkToDeath to work.
-        mCameraRecordingProxy->asBinder()->linkToDeath(mDeathNotifier);
-    }
-
-    mCamera->lock();
-
-    return OK;
-}
-
+//TODO: Do we need to reimplement isCameraAvailable?
 
 /*
  * Check to see whether the requested video width and height is one
@@ -267,7 +230,7 @@ static void getSupportedVideoSizes(
  * @param params CameraParameters to retrieve the information
  * @return OK if no error.
  */
-status_t CameraSource::isCameraColorFormatSupported(
+status_t GonkCameraSource::isCameraColorFormatSupported(
         const CameraParameters& params) {
     mColorFormat = getColorFormat(params.get(
             CameraParameters::KEY_VIDEO_FRAME_FORMAT));
@@ -292,7 +255,7 @@ status_t CameraSource::isCameraColorFormatSupported(
  * @param frameRate the target frame rate in frames per second.
  * @return OK if no error.
  */
-status_t CameraSource::configureCamera(
+status_t GonkCameraSource::configureCamera(
         CameraParameters* params,
         int32_t width, int32_t height,
         int32_t frameRate) {
@@ -347,10 +310,9 @@ status_t CameraSource::configureCamera(
 
     if (isCameraParamChanged) {
         // Either frame rate or frame size needs to be changed.
-        String8 s = params->flatten();
-        if (OK != mCamera->setParameters(s)) {
+        if (OK != GonkCameraHardware::PushParameters(mCameraHandle,*params)) {
             LOGE("Could not change settings."
-                 " Someone else is using camera %p?", mCamera.get());
+                 " Someone else is using camera ?");
             return -EBUSY;
         }
     }
@@ -368,7 +330,7 @@ status_t CameraSource::configureCamera(
  * @param the target video frame height in pixels to check against
  * @return OK if no error
  */
-status_t CameraSource::checkVideoSize(
+status_t GonkCameraSource::checkVideoSize(
         const CameraParameters& params,
         int32_t width, int32_t height) {
 
@@ -420,7 +382,7 @@ status_t CameraSource::checkVideoSize(
  * @param the target video frame rate to check against
  * @return OK if no error.
  */
-status_t CameraSource::checkFrameRate(
+status_t GonkCameraSource::checkFrameRate(
         const CameraParameters& params,
         int32_t frameRate) {
 
@@ -462,39 +424,17 @@ status_t CameraSource::checkFrameRate(
  *
  * @return OK if no error.
  */
-status_t CameraSource::init(
-        const sp<ICamera>& camera,
-        const sp<ICameraRecordingProxy>& proxy,
-        int32_t cameraId,
+status_t GonkCameraSource::init(
         Size videoSize,
         int32_t frameRate,
         bool storeMetaDataInVideoBuffers) {
 
     LOGV("init");
     status_t err = OK;
-    int64_t token = IPCThreadState::self()->clearCallingIdentity();
-    err = initWithCameraAccess(camera, proxy, cameraId,
-                               videoSize, frameRate,
-                               storeMetaDataInVideoBuffers);
-    IPCThreadState::self()->restoreCallingIdentity(token);
-    return err;
-}
-
-status_t CameraSource::initWithCameraAccess(
-        const sp<ICamera>& camera,
-        const sp<ICameraRecordingProxy>& proxy,
-        int32_t cameraId,
-        Size videoSize,
-        int32_t frameRate,
-        bool storeMetaDataInVideoBuffers) {
-    LOGV("initWithCameraAccess");
-    status_t err = OK;
+    //TODO: need to do something here to check the sanity of camera
 
-    if ((err = isCameraAvailable(camera, proxy, cameraId)) != OK) {
-        LOGE("Camera connection could not be established.");
-        return err;
-    }
-    CameraParameters params(mCamera->getParameters());
+    CameraParameters params;
+    GonkCameraHardware::PullParameters(mCameraHandle, params);
     if ((err = isCameraColorFormatSupported(params)) != OK) {
         return err;
     }
@@ -508,7 +448,8 @@ status_t CameraSource::initWithCameraAccess(
     }
 
     // Check on video frame size and frame rate.
-    CameraParameters newCameraParams(mCamera->getParameters());
+    CameraParameters newCameraParams;
+    GonkCameraHardware::PullParameters(mCameraHandle, newCameraParams);
     if ((err = checkVideoSize(newCameraParams,
                 videoSize.width, videoSize.height)) != OK) {
         return err;
@@ -517,15 +458,11 @@ status_t CameraSource::initWithCameraAccess(
         return err;
     }
 
-    // This CHECK is good, since we just passed the lock/unlock
-    // check earlier by calling mCamera->setParameters().
-    CHECK_EQ(OK, mCamera->setPreviewDisplay(mSurface));
-
     // By default, do not store metadata in video buffers
     mIsMetaDataStoredInVideoBuffers = false;
-    mCamera->storeMetaDataInBuffers(false);
+    GonkCameraHardware::StoreMetaDataInBuffers(mCameraHandle, false);
     if (storeMetaDataInVideoBuffers) {
-        if (OK == mCamera->storeMetaDataInBuffers(true)) {
+        if (OK == GonkCameraHardware::StoreMetaDataInBuffers(mCameraHandle, true)) {
             mIsMetaDataStoredInVideoBuffers = true;
         }
     }
@@ -568,40 +505,28 @@ status_t CameraSource::initWithCameraAccess(
     return OK;
 }
 
-CameraSource::~CameraSource() {
+GonkCameraSource::~GonkCameraSource() {
     if (mStarted) {
         stop();
     } else if (mInitCheck == OK) {
         // Camera is initialized but because start() is never called,
         // the lock on Camera is never released(). This makes sure
         // Camera's lock is released in this case.
+        // TODO: Don't think I need to do this
         releaseCamera();
     }
 }
 
-void CameraSource::startCameraRecording() {
+void GonkCameraSource::startCameraRecording() {
     LOGV("startCameraRecording");
-    // Reset the identity to the current thread because media server owns the
-    // camera and recording is started by the applications. The applications
-    // will connect to the camera in ICameraRecordingProxy::startRecording.
-    int64_t token = IPCThreadState::self()->clearCallingIdentity();
-    if (mCameraFlags & FLAGS_HOT_CAMERA) {
-        mCamera->unlock();
-        mCamera.clear();
-        CHECK_EQ(OK, mCameraRecordingProxy->startRecording(new ProxyListener(this)));
-    } else {
-        mCamera->setListener(new CameraSourceListener(this));
-        mCamera->startRecording();
-        CHECK(mCamera->recordingEnabled());
-    }
-    IPCThreadState::self()->restoreCallingIdentity(token);
+    CHECK_EQ(OK, GonkCameraHardware::StartRecording(mCameraHandle));
 }
 
-status_t CameraSource::start(MetaData *meta) {
+status_t GonkCameraSource::start(MetaData *meta) {
     LOGV("start");
     CHECK(!mStarted);
     if (mInitCheck != OK) {
-        LOGE("CameraSource is not initialized yet");
+        LOGE("GonkCameraSource is not initialized yet");
         return mInitCheck;
     }
 
@@ -614,58 +539,34 @@ status_t CameraSource::start(MetaData *meta) {
     mStartTimeUs = 0;
     int64_t startTimeUs;
     if (meta && meta->findInt64(kKeyTime, &startTimeUs)) {
+        LOGV("Metadata enabled, startime: %lld us", startTimeUs);
         mStartTimeUs = startTimeUs;
     }
 
+    // Register a listener with GonkCameraHardware so that we can get callbacks
+    GonkCameraHardware::SetListener(mCameraHandle, new GonkCameraSourceListener(this));
+
     startCameraRecording();
 
     mStarted = true;
     return OK;
 }
 
-void CameraSource::stopCameraRecording() {
+void GonkCameraSource::stopCameraRecording() {
     LOGV("stopCameraRecording");
-    if (mCameraFlags & FLAGS_HOT_CAMERA) {
-        mCameraRecordingProxy->stopRecording();
-    } else {
-        mCamera->setListener(NULL);
-        mCamera->stopRecording();
-    }
+    GonkCameraHardware::StopRecording(mCameraHandle);
 }
 
-void CameraSource::releaseCamera() {
+void GonkCameraSource::releaseCamera() {
     LOGV("releaseCamera");
-    if (mCamera != 0) {
-        int64_t token = IPCThreadState::self()->clearCallingIdentity();
-        if ((mCameraFlags & FLAGS_HOT_CAMERA) == 0) {
-            LOGV("Camera was cold when we started, stopping preview");
-            mCamera->stopPreview();
-            mCamera->disconnect();
-        }
-        mCamera->unlock();
-        mCamera.clear();
-        mCamera = 0;
-        IPCThreadState::self()->restoreCallingIdentity(token);
-    }
-    if (mCameraRecordingProxy != 0) {
-        mCameraRecordingProxy->asBinder()->unlinkToDeath(mDeathNotifier);
-        mCameraRecordingProxy.clear();
-    }
-    mCameraFlags = 0;
 }
 
-status_t CameraSource::stop() {
-    LOGD("stop: E");
+status_t GonkCameraSource::stop() {
+    LOGV("stop: E");
     Mutex::Autolock autoLock(mLock);
     mStarted = false;
     mFrameAvailableCondition.signal();
 
-    int64_t token;
-    bool isTokenValid = false;
-    if (mCamera != 0) {
-        token = IPCThreadState::self()->clearCallingIdentity();
-        isTokenValid = true;
-    }
     releaseQueuedFrames();
     while (!mFramesBeingEncoded.empty()) {
         if (NO_ERROR !=
@@ -675,11 +576,9 @@ status_t CameraSource::stop() {
                 mFramesBeingEncoded.size());
         }
     }
+    LOGV("Calling stopCameraRecording");
     stopCameraRecording();
     releaseCamera();
-    if (isTokenValid) {
-        IPCThreadState::self()->restoreCallingIdentity(token);
-    }
 
     if (mCollectStats) {
         LOGI("Frames received/encoded/dropped: %d/%d/%d in %lld us",
@@ -692,22 +591,16 @@ status_t CameraSource::stop() {
     }
 
     CHECK_EQ(mNumFramesReceived, mNumFramesEncoded + mNumFramesDropped);
-    LOGD("stop: X");
+    LOGV("stop: X");
     return OK;
 }
 
-void CameraSource::releaseRecordingFrame(const sp<IMemory>& frame) {
+void GonkCameraSource::releaseRecordingFrame(const sp<IMemory>& frame) {
     LOGV("releaseRecordingFrame");
-    if (mCameraRecordingProxy != NULL) {
-        mCameraRecordingProxy->releaseRecordingFrame(frame);
-    } else if (mCamera != NULL) {
-        int64_t token = IPCThreadState::self()->clearCallingIdentity();
-        mCamera->releaseRecordingFrame(frame);
-        IPCThreadState::self()->restoreCallingIdentity(token);
-    }
+    GonkCameraHardware::ReleaseRecordingFrame(mCameraHandle, frame);
 }
 
-void CameraSource::releaseQueuedFrames() {
+void GonkCameraSource::releaseQueuedFrames() {
     List<sp<IMemory> >::iterator it;
     while (!mFramesReceived.empty()) {
         it = mFramesReceived.begin();
@@ -717,15 +610,15 @@ void CameraSource::releaseQueuedFrames() {
     }
 }
 
-sp<MetaData> CameraSource::getFormat() {
+sp<MetaData> GonkCameraSource::getFormat() {
     return mMeta;
 }
 
-void CameraSource::releaseOneRecordingFrame(const sp<IMemory>& frame) {
+void GonkCameraSource::releaseOneRecordingFrame(const sp<IMemory>& frame) {
     releaseRecordingFrame(frame);
 }
 
-void CameraSource::signalBufferReturned(MediaBuffer *buffer) {
+void GonkCameraSource::signalBufferReturned(MediaBuffer *buffer) {
     LOGV("signalBufferReturned: %p", buffer->data());
     Mutex::Autolock autoLock(mLock);
     for (List<sp<IMemory> >::iterator it = mFramesBeingEncoded.begin();
@@ -743,7 +636,7 @@ void CameraSource::signalBufferReturned(MediaBuffer *buffer) {
     CHECK_EQ(0, "signalBufferReturned: bogus buffer");
 }
 
-status_t CameraSource::read(
+status_t GonkCameraSource::read(
         MediaBuffer **buffer, const ReadOptions *options) {
     LOGV("read");
 
@@ -764,11 +657,7 @@ status_t CameraSource::read(
             if (NO_ERROR !=
                 mFrameAvailableCondition.waitRelative(mLock,
                     mTimeBetweenFrameCaptureUs * 1000LL + CAMERA_SOURCE_TIMEOUT_NS)) {
-                if (mCameraRecordingProxy != 0 &&
-                    !mCameraRecordingProxy->asBinder()->isBinderAlive()) {
-                    LOGW("camera recording proxy is gone");
-                    return ERROR_END_OF_STREAM;
-                }
+                //TODO: check sanity of camera?
                 LOGW("Timed out waiting for incoming camera video frames: %lld us",
                     mLastFrameTimestampUs);
             }
@@ -790,9 +679,10 @@ status_t CameraSource::read(
     return OK;
 }
 
-void CameraSource::dataCallbackTimestamp(int64_t timestampUs,
+void GonkCameraSource::dataCallbackTimestamp(int64_t timestampUs,
         int32_t msgType, const sp<IMemory> &data) {
     LOGV("dataCallbackTimestamp: timestamp %lld us", timestampUs);
+    //LOGV("dataCallbackTimestamp: data %x size %d", data->pointer(), data->size());
     Mutex::Autolock autoLock(mLock);
     if (!mStarted || (mNumFramesReceived == 0 && timestampUs < mStartTimeUs)) {
         LOGV("Drop frame at %lld/%lld us", timestampUs, mStartTimeUs);
@@ -808,7 +698,7 @@ void CameraSource::dataCallbackTimestamp(int64_t timestampUs,
     }
 
     // May need to skip frame or modify timestamp. Currently implemented
-    // by the subclass CameraSourceTimeLapse.
+    // by the subclass GonkCameraSourceTimeLapse.
     if (skipCurrentFrame(timestampUs)) {
         releaseOneRecordingFrame(data);
         return;
@@ -839,22 +729,9 @@ void CameraSource::dataCallbackTimestamp(int64_t timestampUs,
     mFrameAvailableCondition.signal();
 }
 
-bool CameraSource::isMetaDataStoredInVideoBuffers() const {
+bool GonkCameraSource::isMetaDataStoredInVideoBuffers() const {
     LOGV("isMetaDataStoredInVideoBuffers");
     return mIsMetaDataStoredInVideoBuffers;
 }
 
-CameraSource::ProxyListener::ProxyListener(const sp<CameraSource>& source) {
-    mSource = source;
-}
-
-void CameraSource::ProxyListener::dataCallbackTimestamp(
-        nsecs_t timestamp, int32_t msgType, const sp<IMemory>& dataPtr) {
-    mSource->dataCallbackTimestamp(timestamp / 1000, msgType, dataPtr);
-}
-
-void CameraSource::DeathNotifier::binderDied(const wp<IBinder>& who) {
-    LOGI("Camera recording proxy died");
-}
-
-}  // namespace android
+} // namespace android
diff --git a/GonkCameraSource.h b/GonkCameraSource.h
index 446720b..fe58f96 100644
--- a/GonkCameraSource.h
+++ b/GonkCameraSource.h
@@ -14,69 +14,31 @@
  * limitations under the License.
  */
 
-#ifndef CAMERA_SOURCE_H_
+#ifndef GONK_CAMERA_SOURCE_H_
 
-#define CAMERA_SOURCE_H_
+#define GONK_CAMERA_SOURCE_H_
 
 #include <media/stagefright/MediaBuffer.h>
 #include <media/stagefright/MediaSource.h>
-#include <camera/ICamera.h>
-#include <camera/ICameraRecordingProxyListener.h>
 #include <camera/CameraParameters.h>
 #include <utils/List.h>
 #include <utils/RefBase.h>
+#include <utils/threads.h>
 
 namespace android {
 
 class IMemory;
-class Camera;
-class Surface;
+class GonkCameraSourceListener;
 
-class CameraSource : public MediaSource, public MediaBufferObserver {
+class GonkCameraSource : public MediaSource, public MediaBufferObserver {
 public:
-    /**
-     * Factory method to create a new CameraSource using the current
-     * settings (such as video size, frame rate, color format, etc)
-     * from the default camera.
-     *
-     * @return NULL on error.
-     */
-    static CameraSource *Create();
 
-    /**
-     * Factory method to create a new CameraSource.
-     *
-     * @param camera the video input frame data source. If it is NULL,
-     *          we will try to connect to the camera with the given
-     *          cameraId.
-     *
-     * @param cameraId the id of the camera that the source will connect
-     *          to if camera is NULL; otherwise ignored.
-     *
-     * @param videoSize the dimension (in pixels) of the video frame
-     * @param frameRate the target frames per second
-     * @param surface the preview surface for display where preview
-     *          frames are sent to
-     * @param storeMetaDataInVideoBuffers true to request the camera
-     *          source to store meta data in video buffers; false to
-     *          request the camera source to store real YUV frame data
-     *          in the video buffers. The camera source may not support
-     *          storing meta data in video buffers, if so, a request
-     *          to do that will NOT be honored. To find out whether
-     *          meta data is actually being stored in video buffers
-     *          during recording, call isMetaDataStoredInVideoBuffers().
-     *
-     * @return NULL on error.
-     */
-    static CameraSource *CreateFromCamera(const sp<ICamera> &camera,
-                                          const sp<ICameraRecordingProxy> &proxy,
-                                          int32_t cameraId,
-                                          Size videoSize,
-                                          int32_t frameRate,
-                                          const sp<Surface>& surface,
-                                          bool storeMetaDataInVideoBuffers = false);
+    static GonkCameraSource *Create(int32_t cameraHandle,
+                                    Size videoSize,
+                                    int32_t frameRate,
+                                    bool storeMetaDataInVideoBuffers = false);
 
-    virtual ~CameraSource();
+    virtual ~GonkCameraSource();
 
     virtual status_t start(MetaData *params = NULL);
     virtual status_t stop();
@@ -84,14 +46,14 @@ public:
             MediaBuffer **buffer, const ReadOptions *options = NULL);
 
     /**
-     * Check whether a CameraSource object is properly initialized.
+     * Check whether a GonkCameraSource object is properly initialized.
      * Must call this method before stop().
      * @return OK if initialization has successfully completed.
      */
     virtual status_t initCheck() const;
 
     /**
-     * Returns the MetaData associated with the CameraSource,
+     * Returns the MetaData associated with the GonkCameraSource,
      * including:
      * kKeyColorFormat: YUV color format of the video frames
      * kKeyWidth, kKeyHeight: dimension (in pixels) of the video frames
@@ -113,22 +75,6 @@ public:
     virtual void signalBufferReturned(MediaBuffer* buffer);
 
 protected:
-    class ProxyListener: public BnCameraRecordingProxyListener {
-    public:
-        ProxyListener(const sp<CameraSource>& source);
-        virtual void dataCallbackTimestamp(int64_t timestampUs, int32_t msgType,
-                const sp<IMemory> &data);
-
-    private:
-        sp<CameraSource> mSource;
-    };
-
-    // isBinderAlive needs linkToDeath to work.
-    class DeathNotifier: public IBinder::DeathRecipient {
-    public:
-        DeathNotifier() {}
-        virtual void binderDied(const wp<IBinder>& who);
-    };
 
     enum CameraFlags {
         FLAGS_SET_CAMERA = 1L << 0,
@@ -141,10 +87,6 @@ protected:
     int32_t  mColorFormat;
     status_t mInitCheck;
 
-    sp<Camera>   mCamera;
-    sp<ICameraRecordingProxy>   mCameraRecordingProxy;
-    sp<DeathNotifier> mDeathNotifier;
-    sp<Surface>  mSurface;
     sp<MetaData> mMeta;
 
     int64_t mStartTimeUs;
@@ -156,11 +98,9 @@ protected:
     // Time between capture of two frames.
     int64_t mTimeBetweenFrameCaptureUs;
 
-    CameraSource(const sp<ICamera>& camera, const sp<ICameraRecordingProxy>& proxy,
-                 int32_t cameraId,
+    GonkCameraSource(int32_t cameraHandle,
                  Size videoSize, int32_t frameRate,
-                 const sp<Surface>& surface,
-                 bool storeMetaDataInVideoBuffers);
+                 bool storeMetaDataInVideoBuffers = false);
 
     virtual void startCameraRecording();
     virtual void stopCameraRecording();
@@ -170,6 +110,7 @@ protected:
     // Called from dataCallbackTimestamp.
     virtual bool skipCurrentFrame(int64_t timestampUs) {return false;}
 
+    friend class GonkCameraSourceListener;
     // Callback called when still camera raw data is available.
     virtual void dataCallback(int32_t msgType, const sp<IMemory> &data) {}
 
@@ -177,7 +118,6 @@ protected:
             const sp<IMemory> &data);
 
 private:
-    friend class CameraSourceListener;
 
     Mutex mLock;
     Condition mFrameAvailableCondition;
@@ -192,23 +132,13 @@ private:
     int64_t mGlitchDurationThresholdUs;
     bool mCollectStats;
     bool mIsMetaDataStoredInVideoBuffers;
+    int32_t mCameraHandle;
 
     void releaseQueuedFrames();
     void releaseOneRecordingFrame(const sp<IMemory>& frame);
 
-
-    status_t init(const sp<ICamera>& camera, const sp<ICameraRecordingProxy>& proxy,
-                  int32_t cameraId, Size videoSize, int32_t frameRate,
-                  bool storeMetaDataInVideoBuffers);
-
-    status_t initWithCameraAccess(
-                  const sp<ICamera>& camera, const sp<ICameraRecordingProxy>& proxy,
-                  int32_t cameraId, Size videoSize, int32_t frameRate,
+    status_t init(Size videoSize, int32_t frameRate,
                   bool storeMetaDataInVideoBuffers);
-
-    status_t isCameraAvailable(const sp<ICamera>& camera,
-                               const sp<ICameraRecordingProxy>& proxy,
-                               int32_t cameraId);
     status_t isCameraColorFormatSupported(const CameraParameters& params);
     status_t configureCamera(CameraParameters* params,
                     int32_t width, int32_t height,
@@ -222,10 +152,10 @@ private:
 
     void releaseCamera();
 
-    CameraSource(const CameraSource &);
-    CameraSource &operator=(const CameraSource &);
+    GonkCameraSource(const GonkCameraSource &);
+    GonkCameraSource &operator=(const GonkCameraSource &);
 };
 
 }  // namespace android
 
-#endif  // CAMERA_SOURCE_H_
+#endif  // GONK_CAMERA_SOURCE_H_
diff --git a/GonkRecorder.cpp b/GonkRecorder.cpp
index b20ca9d..2dc625c 100644
--- a/GonkRecorder.cpp
+++ b/GonkRecorder.cpp
@@ -16,35 +16,23 @@
  */
 
 //#define LOG_NDEBUG 0
-#define LOG_TAG "StagefrightRecorder"
+#define LOG_TAG "GonkRecorder"
+
 #include <utils/Log.h>
 #include <media/AudioParameter.h>
-#include "StagefrightRecorder.h"
-
-#include <binder/IPCThreadState.h>
-#include <binder/IServiceManager.h>
+#include "GonkRecorder.h"
 
-#include <media/IMediaPlayerService.h>
 #include <media/stagefright/AudioSource.h>
 #include <media/stagefright/AMRWriter.h>
-#include <media/stagefright/AACWriter.h>
-#include <media/stagefright/ExtendedWriter.h>
-#include <media/stagefright/FMA2DPWriter.h>
-#include <media/stagefright/CameraSource.h>
-#include <media/stagefright/CameraSourceTimeLapse.h>
 #include <media/stagefright/ExtendedWriter.h>
 #include <media/stagefright/MPEG2TSWriter.h>
 #include <media/stagefright/MPEG4Writer.h>
 #include <media/stagefright/MediaDebug.h>
 #include <media/stagefright/MediaDefs.h>
 #include <media/stagefright/MetaData.h>
-#include <media/stagefright/OMXClient.h>
+#include <OMX.h>
 #include <media/stagefright/OMXCodec.h>
-#include <media/stagefright/SurfaceMediaSource.h>
 #include <media/MediaProfiles.h>
-#include <camera/ICamera.h>
-#include <camera/CameraParameters.h>
-#include <surfaceflinger/Surface.h>
 #include <utils/String8.h>
 
 #include <utils/Errors.h>
@@ -57,51 +45,41 @@
 #include "ARTPWriter.h"
 
 #include <cutils/properties.h>
+#include "GonkCameraSource.h"
 
 namespace android {
 
-// To collect the encoder usage for the battery app
-static void addBatteryData(uint32_t params) {
-    sp<IBinder> binder =
-        defaultServiceManager()->getService(String16("media.player"));
-    sp<IMediaPlayerService> service = interface_cast<IMediaPlayerService>(binder);
-    CHECK(service.get() != NULL);
-
-    service->addBatteryData(params);
+static sp<IOMX> sOMX = NULL;
+static sp<IOMX> GetOMX() {
+  if(sOMX.get() == NULL) {
+    sOMX = new OMX;
+    }
+  return sOMX;
 }
 
-
-StagefrightRecorder::StagefrightRecorder()
+GonkRecorder::GonkRecorder()
     : mWriter(NULL),
       mOutputFd(-1),
       mAudioSource(AUDIO_SOURCE_CNT),
       mVideoSource(VIDEO_SOURCE_LIST_END),
-      mStarted(false), mSurfaceMediaSource(NULL),
+      mStarted(false),
       mDisableAudio(false) {
 
     LOGV("Constructor");
     reset();
 }
 
-StagefrightRecorder::~StagefrightRecorder() {
+GonkRecorder::~GonkRecorder() {
     LOGV("Destructor");
     stop();
 }
 
-status_t StagefrightRecorder::init() {
+status_t GonkRecorder::init() {
     LOGV("init");
     return OK;
 }
 
-// The client side of mediaserver asks it to creat a SurfaceMediaSource
-// and return a interface reference. The client side will use that
-// while encoding GL Frames
-sp<ISurfaceTexture> StagefrightRecorder::querySurfaceMediaSource() const {
-    LOGV("Get SurfaceMediaSource");
-    return mSurfaceMediaSource;
-}
-
-status_t StagefrightRecorder::setAudioSource(audio_source_t as) {
+status_t GonkRecorder::setAudioSource(audio_source_t as) {
     LOGV("setAudioSource: %d", as);
     if (as < AUDIO_SOURCE_DEFAULT ||
         as >= AUDIO_SOURCE_CNT) {
@@ -122,7 +100,7 @@
     return OK;
 }
 
-status_t StagefrightRecorder::setVideoSource(video_source vs) {
+status_t GonkRecorder::setVideoSource(video_source vs) {
     LOGV("setVideoSource: %d", vs);
     if (vs < VIDEO_SOURCE_DEFAULT ||
         vs >= VIDEO_SOURCE_LIST_END) {
@@ -139,7 +117,7 @@
     return OK;
 }
 
-status_t StagefrightRecorder::setOutputFormat(output_format of) {
+status_t GonkRecorder::setOutputFormat(output_format of) {
     LOGV("setOutputFormat: %d", of);
     if (of < OUTPUT_FORMAT_DEFAULT ||
         of >= OUTPUT_FORMAT_LIST_END) {
@@ -156,7 +134,7 @@
     return OK;
 }
 
-status_t StagefrightRecorder::setAudioEncoder(audio_encoder ae) {
+status_t GonkRecorder::setAudioEncoder(audio_encoder ae) {
     LOGV("setAudioEncoder: %d", ae);
     if (ae < AUDIO_ENCODER_DEFAULT ||
         ae >= AUDIO_ENCODER_LIST_END) {
@@ -174,21 +152,10 @@
         mAudioEncoder = ae;
     }
 
-    // Use default values if appropriate setparam's weren't called.
-    if(mAudioEncoder == AUDIO_ENCODER_AAC) {
-        mSampleRate = mSampleRate ? mSampleRate : 48000;
-        mAudioChannels = mAudioChannels ? mAudioChannels : 2;
-        mAudioBitRate = mAudioBitRate ? mAudioBitRate : 156000;
-    }
-    else{
-        mSampleRate = mSampleRate ? mSampleRate : 8000;
-        mAudioChannels = mAudioChannels ? mAudioChannels : 1;
-        mAudioBitRate = mAudioBitRate ? mAudioBitRate : 12200;
-    }
     return OK;
 }
 
-status_t StagefrightRecorder::setVideoEncoder(video_encoder ve) {
+status_t GonkRecorder::setVideoEncoder(video_encoder ve) {
     LOGV("setVideoEncoder: %d", ve);
     if (ve < VIDEO_ENCODER_DEFAULT ||
         ve >= VIDEO_ENCODER_LIST_END) {
@@ -205,7 +172,7 @@
     return OK;
 }
 
-status_t StagefrightRecorder::setVideoSize(int width, int height) {
+status_t GonkRecorder::setVideoSize(int width, int height) {
     LOGV("setVideoSize: %dx%d", width, height);
     if (width <= 0 || height <= 0) {
         LOGE("Invalid video size: %dx%d", width, height);
@@ -219,7 +186,7 @@
     return OK;
 }
 
-status_t StagefrightRecorder::setVideoFrameRate(int frames_per_second) {
+status_t GonkRecorder::setVideoFrameRate(int frames_per_second) {
     LOGV("setVideoFrameRate: %d", frames_per_second);
     if ((frames_per_second <= 0 && frames_per_second != -1) ||
         frames_per_second > 120) {
@@ -233,31 +200,7 @@
     return OK;
 }
 
-status_t StagefrightRecorder::setCamera(const sp<ICamera> &camera,
-                                        const sp<ICameraRecordingProxy> &proxy) {
-    LOGV("setCamera");
-    if (camera == 0) {
-        LOGE("camera is NULL");
-        return BAD_VALUE;
-    }
-    if (proxy == 0) {
-        LOGE("camera proxy is NULL");
-        return BAD_VALUE;
-    }
-
-    mCamera = camera;
-    mCameraProxy = proxy;
-    return OK;
-}
-
-status_t StagefrightRecorder::setPreviewSurface(const sp<Surface> &surface) {
-    LOGV("setPreviewSurface: %p", surface.get());
-    mPreviewSurface = surface;
-
-    return OK;
-}
-
-status_t StagefrightRecorder::setOutputFile(const char *path) {
+status_t GonkRecorder::setOutputFile(const char *path) {
     LOGE("setOutputFile(const char*) must not be called");
     // We don't actually support this at all, as the media_server process
     // no longer has permissions to create files.
@@ -265,7 +208,7 @@
     return -EPERM;
 }
 
-status_t StagefrightRecorder::setOutputFile(int fd, int64_t offset, int64_t length) {
+status_t GonkRecorder::setOutputFile(int fd, int64_t offset, int64_t length) {
     LOGV("setOutputFile: %d, %lld, %lld", fd, offset, length);
     // These don't make any sense, do they?
     CHECK_EQ(offset, 0);
@@ -339,7 +282,7 @@
     s->setTo(String8(&data[leading_space], i - leading_space));
 }
 
-status_t StagefrightRecorder::setParamAudioSamplingRate(int32_t sampleRate) {
+status_t GonkRecorder::setParamAudioSamplingRate(int32_t sampleRate) {
     LOGV("setParamAudioSamplingRate: %d", sampleRate);
     if (sampleRate <= 0) {
         LOGE("Invalid audio sampling rate: %d", sampleRate);
@@ -351,7 +294,7 @@
     return OK;
 }
 
-status_t StagefrightRecorder::setParamAudioNumberOfChannels(int32_t channels) {
+status_t GonkRecorder::setParamAudioNumberOfChannels(int32_t channels) {
     LOGV("setParamAudioNumberOfChannels: %d", channels);
     if (channels <= 0 || channels >= 3) {
         LOGE("Invalid number of audio channels: %d", channels);
@@ -363,7 +306,7 @@
     return OK;
 }
 
-status_t StagefrightRecorder::setParamAudioEncodingBitRate(int32_t bitRate) {
+status_t GonkRecorder::setParamAudioEncodingBitRate(int32_t bitRate) {
     LOGV("setParamAudioEncodingBitRate: %d", bitRate);
     if (bitRate <= 0) {
         LOGE("Invalid audio encoding bit rate: %d", bitRate);
@@ -378,7 +321,7 @@
     return OK;
 }
 
-status_t StagefrightRecorder::setParamVideoEncodingBitRate(int32_t bitRate) {
+status_t GonkRecorder::setParamVideoEncodingBitRate(int32_t bitRate) {
     LOGV("setParamVideoEncodingBitRate: %d", bitRate);
     if (bitRate <= 0) {
         LOGE("Invalid video encoding bit rate: %d", bitRate);
@@ -394,7 +337,7 @@
 }
 
 // Always rotate clockwise, and only support 0, 90, 180 and 270 for now.
-status_t StagefrightRecorder::setParamVideoRotation(int32_t degrees) {
+status_t GonkRecorder::setParamVideoRotation(int32_t degrees) {
     LOGV("setParamVideoRotation: %d", degrees);
     if (degrees < 0 || degrees % 90 != 0) {
         LOGE("Unsupported video rotation angle: %d", degrees);
@@ -404,7 +347,7 @@
     return OK;
 }
 
-status_t StagefrightRecorder::setParamMaxFileDurationUs(int64_t timeUs) {
+status_t GonkRecorder::setParamMaxFileDurationUs(int64_t timeUs) {
     LOGV("setParamMaxFileDurationUs: %lld us", timeUs);
 
     // This is meant for backward compatibility for MediaRecorder.java
@@ -423,7 +366,7 @@
     return OK;
 }
 
-status_t StagefrightRecorder::setParamMaxFileSizeBytes(int64_t bytes) {
+status_t GonkRecorder::setParamMaxFileSizeBytes(int64_t bytes) {
     LOGV("setParamMaxFileSizeBytes: %lld bytes", bytes);
 
     // This is meant for backward compatibility for MediaRecorder.java
@@ -449,7 +392,7 @@
     return OK;
 }
 
-status_t StagefrightRecorder::setParamInterleaveDuration(int32_t durationUs) {
+status_t GonkRecorder::setParamInterleaveDuration(int32_t durationUs) {
     LOGV("setParamInterleaveDuration: %d", durationUs);
     if (durationUs <= 500000) {           //  500 ms
         // If interleave duration is too small, it is very inefficient to do
@@ -471,20 +414,20 @@
 // If seconds <  0, only the first frame is I frame, and rest are all P frames
 // If seconds == 0, all frames are encoded as I frames. No P frames
 // If seconds >  0, it is the time spacing (seconds) between 2 neighboring I frames
-status_t StagefrightRecorder::setParamVideoIFramesInterval(int32_t seconds) {
+status_t GonkRecorder::setParamVideoIFramesInterval(int32_t seconds) {
     LOGV("setParamVideoIFramesInterval: %d seconds", seconds);
     mIFramesIntervalSec = seconds;
     return OK;
 }
 
-status_t StagefrightRecorder::setParam64BitFileOffset(bool use64Bit) {
+status_t GonkRecorder::setParam64BitFileOffset(bool use64Bit) {
     LOGV("setParam64BitFileOffset: %s",
         use64Bit? "use 64 bit file offset": "use 32 bit file offset");
     mUse64BitFileOffset = use64Bit;
     return OK;
 }
 
-status_t StagefrightRecorder::setParamVideoCameraId(int32_t cameraId) {
+status_t GonkRecorder::setParamVideoCameraId(int32_t cameraId) {
     LOGV("setParamVideoCameraId: %d", cameraId);
     if (cameraId < 0) {
         return BAD_VALUE;
@@ -493,7 +436,7 @@
     return OK;
 }
 
-status_t StagefrightRecorder::setParamTrackTimeStatus(int64_t timeDurationUs) {
+status_t GonkRecorder::setParamTrackTimeStatus(int64_t timeDurationUs) {
     LOGV("setParamTrackTimeStatus: %lld", timeDurationUs);
     if (timeDurationUs < 20000) {  // Infeasible if shorter than 20 ms?
         LOGE("Tracking time duration too short: %lld us", timeDurationUs);
@@ -503,7 +446,7 @@
     return OK;
 }
 
-status_t StagefrightRecorder::setParamVideoEncoderProfile(int32_t profile) {
+status_t GonkRecorder::setParamVideoEncoderProfile(int32_t profile) {
     LOGV("setParamVideoEncoderProfile: %d", profile);
 
     // Additional check will be done later when we load the encoder.
@@ -512,7 +455,7 @@
     return OK;
 }
 
-status_t StagefrightRecorder::setParamVideoEncoderLevel(int32_t level) {
+status_t GonkRecorder::setParamVideoEncoderLevel(int32_t level) {
     LOGV("setParamVideoEncoderLevel: %d", level);
 
     // Additional check will be done later when we load the encoder.
@@ -521,7 +464,7 @@
     return OK;
 }
 
-status_t StagefrightRecorder::setParamMovieTimeScale(int32_t timeScale) {
+status_t GonkRecorder::setParamMovieTimeScale(int32_t timeScale) {
     LOGV("setParamMovieTimeScale: %d", timeScale);
 
     // The range is set to be the same as the audio's time scale range
@@ -534,7 +477,7 @@
     return OK;
 }
 
-status_t StagefrightRecorder::setParamVideoTimeScale(int32_t timeScale) {
+status_t GonkRecorder::setParamVideoTimeScale(int32_t timeScale) {
     LOGV("setParamVideoTimeScale: %d", timeScale);
 
     // 60000 is chosen to make sure that each video frame from a 60-fps
@@ -547,7 +490,7 @@
     return OK;
 }
 
-status_t StagefrightRecorder::setParamAudioTimeScale(int32_t timeScale) {
+status_t GonkRecorder::setParamAudioTimeScale(int32_t timeScale) {
     LOGV("setParamAudioTimeScale: %d", timeScale);
 
     // 96000 Hz is the highest sampling rate support in AAC.
@@ -559,33 +502,7 @@
     return OK;
 }
 
-status_t StagefrightRecorder::setParamTimeLapseEnable(int32_t timeLapseEnable) {
-    LOGV("setParamTimeLapseEnable: %d", timeLapseEnable);
-
-    if(timeLapseEnable == 0) {
-        mCaptureTimeLapse = false;
-    } else if (timeLapseEnable == 1) {
-        mCaptureTimeLapse = true;
-    } else {
-        return BAD_VALUE;
-    }
-    return OK;
-}
-
-status_t StagefrightRecorder::setParamTimeBetweenTimeLapseFrameCapture(int64_t timeUs) {
-    LOGV("setParamTimeBetweenTimeLapseFrameCapture: %lld us", timeUs);
-
-    // Not allowing time more than a day
-    if (timeUs <= 0 || timeUs > 86400*1E6) {
-        LOGE("Time between time lapse frame capture (%lld) is out of range [0, 1 Day]", timeUs);
-        return BAD_VALUE;
-    }
-
-    mTimeBetweenTimeLapseFrameCaptureUs = timeUs;
-    return OK;
-}
-
-status_t StagefrightRecorder::setParamGeoDataLongitude(
+status_t GonkRecorder::setParamGeoDataLongitude(
     int64_t longitudex10000) {
 
     if (longitudex10000 > 1800000 || longitudex10000 < -1800000) {
@@ -595,7 +512,7 @@
     return OK;
 }
 
-status_t StagefrightRecorder::setParamGeoDataLatitude(
+status_t GonkRecorder::setParamGeoDataLatitude(
     int64_t latitudex10000) {
 
     if (latitudex10000 > 900000 || latitudex10000 < -900000) {
@@ -605,7 +522,7 @@
     return OK;
 }
 
-status_t StagefrightRecorder::setParameter(
+status_t GonkRecorder::setParameter(
         const String8 &key, const String8 &value) {
     LOGV("setParameter: key (%s) => value (%s)", key.string(), value.string());
     if (key == "max-duration") {
@@ -703,24 +620,13 @@
         if (safe_strtoi32(value.string(), &timeScale)) {
             return setParamVideoTimeScale(timeScale);
         }
-    } else if (key == "time-lapse-enable") {
-        int32_t timeLapseEnable;
-        if (safe_strtoi32(value.string(), &timeLapseEnable)) {
-            return setParamTimeLapseEnable(timeLapseEnable);
-        }
-    } else if (key == "time-between-time-lapse-frame-capture") {
-        int64_t timeBetweenTimeLapseFrameCaptureMs;
-        if (safe_strtoi64(value.string(), &timeBetweenTimeLapseFrameCaptureMs)) {
-            return setParamTimeBetweenTimeLapseFrameCapture(
-                    1000LL * timeBetweenTimeLapseFrameCaptureMs);
-        }
     } else {
         LOGE("setParameter: failed to find key %s", key.string());
     }
     return BAD_VALUE;
 }
 
-status_t StagefrightRecorder::setParameters(const String8 &params) {
+status_t GonkRecorder::setParameters(const String8 &params) {
     LOGV("setParameters: %s", params.string());
     const char *cparams = params.string();
     const char *key_start = cparams;
@@ -755,13 +661,13 @@
     return OK;
 }
 
-status_t StagefrightRecorder::setListener(const sp<IMediaRecorderClient> &listener) {
+status_t GonkRecorder::setListener(const sp<IMediaRecorderClient> &listener) {
     mListener = listener;
 
     return OK;
 }
 
-status_t StagefrightRecorder::prepare() {
+status_t GonkRecorder::prepare() {
   LOGV(" %s E", __func__ );
 
   if(mVideoSource != VIDEO_SOURCE_LIST_END && mVideoEncoder != VIDEO_ENCODER_LIST_END && mVideoHeight && mVideoWidth &&             /*Video recording*/
@@ -776,17 +682,15 @@
   return OK;
 }
 
-status_t StagefrightRecorder::start() {
+status_t GonkRecorder::start() {
     CHECK(mOutputFd >= 0);
 
     if (mWriter != NULL) {
-        LOGE("File writer is not avaialble");
+        LOGE("File writer is not available");
         return UNKNOWN_ERROR;
     }
 
     status_t status = OK;
-    if(AUDIO_SOURCE_FM_RX_A2DP == mAudioSource)
-        return startFMA2DPWriter();
 
     switch (mOutputFormat) {
         case OUTPUT_FORMAT_DEFAULT:
@@ -800,22 +704,9 @@
             status = startAMRRecording();
             break;
 
-        case OUTPUT_FORMAT_AAC_ADIF:
-        case OUTPUT_FORMAT_AAC_ADTS:
-            status = startAACRecording();
-            break;
-
-        case OUTPUT_FORMAT_RTP_AVP:
-            status = startRTPRecording();
-            break;
-
         case OUTPUT_FORMAT_MPEG2TS:
             status = startMPEG2TSRecording();
 		    break;
-			
-        case OUTPUT_FORMAT_QCP:
-            status = startExtendedRecording( );
-		    break;
         default:
             LOGE("Unsupported output file format: %d", mOutputFormat);
             status = UNKNOWN_ERROR;
@@ -824,22 +715,12 @@
 
     if ((status == OK) && (!mStarted)) {
         mStarted = true;
-
-        uint32_t params = IMediaPlayerService::kBatteryDataCodecStarted;
-        if (mAudioSource != AUDIO_SOURCE_CNT) {
-            params |= IMediaPlayerService::kBatteryDataTrackAudio;
-        }
-        if (mVideoSource != VIDEO_SOURCE_LIST_END) {
-            params |= IMediaPlayerService::kBatteryDataTrackVideo;
-        }
-
-        addBatteryData(params);
     }
 
     return status;
 }
 
-sp<MediaSource> StagefrightRecorder::createAudioSource() {
+sp<MediaSource> GonkRecorder::createAudioSource() {
 
     bool tunneledSource = false;
     const char *tunnelMime;
@@ -907,12 +788,6 @@
         case AUDIO_ENCODER_AAC:
             mime = MEDIA_MIMETYPE_AUDIO_AAC;
             break;
-        case AUDIO_ENCODER_EVRC:
-            mime = MEDIA_MIMETYPE_AUDIO_EVRC;
-            break;
-        case AUDIO_ENCODER_QCELP:
-            mime = MEDIA_MIMETYPE_AUDIO_QCELP;
-            break;
         default:
             LOGE("Unknown audio encoder: %d", mAudioEncoder);
             return NULL;
@@ -931,36 +806,17 @@
         encMeta->setInt32(kKeyTimeScale, mAudioTimeScale);
     }
 
-    OMXClient client;
-    CHECK_EQ(client.connect(), OK);
-
+    // use direct OMX interface instead of connecting to
+    // mediaserver over binder calls
     sp<MediaSource> audioEncoder =
-        OMXCodec::Create(client.interface(), encMeta,
+        OMXCodec::Create(GetOMX(), encMeta,
                          true /* createEncoder */, audioSource);
     mAudioSourceNode = audioSource;
 
     return audioEncoder;
 }
 
-status_t StagefrightRecorder::startAACRecording() {
-    // FIXME:
-    // Add support for OUTPUT_FORMAT_AAC_ADIF
-    CHECK(mOutputFormat == OUTPUT_FORMAT_AAC_ADTS);
-
-    CHECK(mAudioEncoder == AUDIO_ENCODER_AAC);
-    CHECK(mAudioSource != AUDIO_SOURCE_CNT);
-
-    mWriter = new AACWriter(mOutputFd);
-    status_t status = startRawAudioRecording();
-    if (status != OK) {
-        mWriter.clear();
-        mWriter = NULL;
-    }
-
-    return status;
-}
-
-status_t StagefrightRecorder::startAMRRecording() {
+status_t GonkRecorder::startAMRRecording() {
     CHECK(mOutputFormat == OUTPUT_FORMAT_AMR_NB ||
           mOutputFormat == OUTPUT_FORMAT_AMR_WB);
 
@@ -971,28 +827,12 @@
                     mAudioEncoder);
             return BAD_VALUE;
         }
-        if (mSampleRate != 8000) {
-            LOGE("Invalid sampling rate %d used for AMRNB recording",
-                    mSampleRate);
-            return BAD_VALUE;
-        }
     } else {  // mOutputFormat must be OUTPUT_FORMAT_AMR_WB
         if (mAudioEncoder != AUDIO_ENCODER_AMR_WB) {
             LOGE("Invlaid encoder %d used for AMRWB recording",
                     mAudioEncoder);
             return BAD_VALUE;
         }
-        if (mSampleRate != 16000) {
-            LOGE("Invalid sample rate %d used for AMRWB recording",
-                    mSampleRate);
-            return BAD_VALUE;
-        }
-    }
-
-    if (mAudioChannels != 1) {
-        LOGE("Invalid number of audio channels %d used for amr recording",
-                mAudioChannels);
-        return BAD_VALUE;
     }
 
     mWriter = new AMRWriter(mOutputFd);
@@ -1004,7 +844,7 @@
     return status;
 }
 
-status_t StagefrightRecorder::startRawAudioRecording() {
+status_t GonkRecorder::startRawAudioRecording() {
     if (mAudioSource >= AUDIO_SOURCE_CNT) {
         LOGE("Invalid audio source: %d", mAudioSource);
         return BAD_VALUE;
@@ -1035,62 +875,7 @@
     return OK;
 }
 
-status_t StagefrightRecorder::startFMA2DPWriter() {
-    /* FM soc outputs at 48k */
-	mSampleRate = 48000;
-	mAudioChannels = 2;
-	
-    sp<MetaData> meta = new MetaData;
-    meta->setInt32(kKeyChannelCount, mAudioChannels);
-    meta->setInt32(kKeySampleRate, mSampleRate);
-
-    mWriter = new FMA2DPWriter();
-    mWriter->setListener(mListener);
-    mWriter->start(meta.get());
-    return OK;
-}
-
-status_t StagefrightRecorder::startRTPRecording() {
-    CHECK_EQ(mOutputFormat, OUTPUT_FORMAT_RTP_AVP);
-
-    if ((mAudioSource != AUDIO_SOURCE_CNT
-                && mVideoSource != VIDEO_SOURCE_LIST_END)
-            || (mAudioSource == AUDIO_SOURCE_CNT
-                && mVideoSource == VIDEO_SOURCE_LIST_END)) {
-        // Must have exactly one source.
-        return BAD_VALUE;
-    }
-
-    if (mOutputFd < 0) {
-        return BAD_VALUE;
-    }
-
-    sp<MediaSource> source;
-
-    if (mAudioSource != AUDIO_SOURCE_CNT) {
-        source = createAudioSource();
-    } else {
-
-        sp<MediaSource> mediaSource;
-        status_t err = setupMediaSource(&mediaSource);
-        if (err != OK) {
-            return err;
-        }
-
-        err = setupVideoEncoder(mediaSource, mVideoBitRate, &source);
-        if (err != OK) {
-            return err;
-        }
-    }
-
-    mWriter = new ARTPWriter(mOutputFd);
-    mWriter->addSource(source);
-    mWriter->setListener(mListener);
-
-    return mWriter->start();
-}
-
-status_t StagefrightRecorder::startMPEG2TSRecording() {
+status_t GonkRecorder::startMPEG2TSRecording() {
     CHECK_EQ(mOutputFormat, OUTPUT_FORMAT_MPEG2TS);
 
     sp<MediaWriter> writer = new MPEG2TSWriter(mOutputFd);
@@ -1141,7 +926,7 @@
     return mWriter->start();
 }
 
-void StagefrightRecorder::clipVideoFrameRate() {
+void GonkRecorder::clipVideoFrameRate() {
     LOGV("clipVideoFrameRate: encoder %d", mVideoEncoder);
     int minFrameRate = mEncoderProfiles->getVideoEncoderParamByName(
                         "enc.vid.fps.min", mVideoEncoder);
@@ -1158,7 +943,7 @@
     }
 }
 
-void StagefrightRecorder::clipVideoBitRate() {
+void GonkRecorder::clipVideoBitRate() {
     LOGV("clipVideoBitRate: encoder %d", mVideoEncoder);
     int minBitRate = mEncoderProfiles->getVideoEncoderParamByName(
                         "enc.vid.bps.min", mVideoEncoder);
@@ -1175,7 +960,7 @@
     }
 }
 
-void StagefrightRecorder::clipVideoFrameWidth() {
+void GonkRecorder::clipVideoFrameWidth() {
     LOGV("clipVideoFrameWidth: encoder %d", mVideoEncoder);
     int minFrameWidth = mEncoderProfiles->getVideoEncoderParamByName(
                         "enc.vid.width.min", mVideoEncoder);
@@ -1192,8 +977,7 @@
     }
 }
 
-status_t StagefrightRecorder::checkVideoEncoderCapabilities() {
-    if (!mCaptureTimeLapse) {
+status_t GonkRecorder::checkVideoEncoderCapabilities() {
         // Dont clip for time lapse capture as encoder will have enough
         // time to encode because of slow capture rate of time lapse.
         clipVideoBitRate();
@@ -1201,13 +985,12 @@
         clipVideoFrameWidth();
         clipVideoFrameHeight();
         setDefaultProfileIfNecessary();
-    }
     return OK;
 }
 
 // Set to use AVC baseline profile if the encoding parameters matches
 // CAMCORDER_QUALITY_LOW profile; this is for the sake of MMS service.
-void StagefrightRecorder::setDefaultProfileIfNecessary() {
+void GonkRecorder::setDefaultProfileIfNecessary() {
     LOGV("setDefaultProfileIfNecessary");
 
     camcorder_quality quality = CAMCORDER_QUALITY_LOW;
@@ -1263,14 +1046,14 @@
     }
 }
 
-status_t StagefrightRecorder::checkAudioEncoderCapabilities() {
+status_t GonkRecorder::checkAudioEncoderCapabilities() {
     clipAudioBitRate();
     clipAudioSampleRate();
     clipNumberOfAudioChannels();
     return OK;
 }
 
-void StagefrightRecorder::clipAudioBitRate() {
+void GonkRecorder::clipAudioBitRate() {
     LOGV("clipAudioBitRate: encoder %d", mAudioEncoder);
 
     int minAudioBitRate =
@@ -1292,7 +1075,7 @@
     }
 }
 
-void StagefrightRecorder::clipAudioSampleRate() {
+void GonkRecorder::clipAudioSampleRate() {
     LOGV("clipAudioSampleRate: encoder %d", mAudioEncoder);
 
     int minSampleRate =
@@ -1314,7 +1097,7 @@
     }
 }
 
-void StagefrightRecorder::clipNumberOfAudioChannels() {
+void GonkRecorder::clipNumberOfAudioChannels() {
     LOGV("clipNumberOfAudioChannels: encoder %d", mAudioEncoder);
 
     int minChannels =
@@ -1336,7 +1119,7 @@
     }
 }
 
-void StagefrightRecorder::clipVideoFrameHeight() {
+void GonkRecorder::clipVideoFrameHeight() {
     LOGV("clipVideoFrameHeight: encoder %d", mVideoEncoder);
     int minFrameHeight = mEncoderProfiles->getVideoEncoderParamByName(
                         "enc.vid.height.min", mVideoEncoder);
@@ -1354,61 +1137,26 @@
 }
 
 // Set up the appropriate MediaSource depending on the chosen option
-status_t StagefrightRecorder::setupMediaSource(
+status_t GonkRecorder::setupMediaSource(
                       sp<MediaSource> *mediaSource) {
     if (mVideoSource == VIDEO_SOURCE_DEFAULT
             || mVideoSource == VIDEO_SOURCE_CAMERA) {
-        sp<CameraSource> cameraSource;
+        sp<GonkCameraSource> cameraSource;
         status_t err = setupCameraSource(&cameraSource);
         if (err != OK) {
             return err;
         }
         *mediaSource = cameraSource;
     } else if (mVideoSource == VIDEO_SOURCE_GRALLOC_BUFFER) {
-        // If using GRAlloc buffers, setup surfacemediasource.
-        // Later a handle to that will be passed
-        // to the client side when queried
-        status_t err = setupSurfaceMediaSource();
-        if (err != OK) {
-            return err;
-        }
-        *mediaSource = mSurfaceMediaSource;
+        return BAD_VALUE;
     } else {
         return INVALID_OPERATION;
     }
     return OK;
 }
 
-// setupSurfaceMediaSource creates a source with the given
-// width and height and framerate.
-// TODO: This could go in a static function inside SurfaceMediaSource
-// similar to that in CameraSource
-status_t StagefrightRecorder::setupSurfaceMediaSource() {
-    status_t err = OK;
-    mSurfaceMediaSource = new SurfaceMediaSource(mVideoWidth, mVideoHeight);
-    if (mSurfaceMediaSource == NULL) {
-        return NO_INIT;
-    }
-
-    if (mFrameRate == -1) {
-        int32_t frameRate = 0;
-        CHECK (mSurfaceMediaSource->getFormat()->findInt32(
-                                        kKeyFrameRate, &frameRate));
-        LOGI("Frame rate is not explicitly set. Use the current frame "
-             "rate (%d fps)", frameRate);
-        mFrameRate = frameRate;
-    } else {
-        err = mSurfaceMediaSource->setFrameRate(mFrameRate);
-    }
-    CHECK(mFrameRate != -1);
-
-    mIsMetaDataStoredInVideoBuffers =
-        mSurfaceMediaSource->isMetaDataStoredInVideoBuffers();
-    return err;
-}
-
-status_t StagefrightRecorder::setupCameraSource(
-        sp<CameraSource> *cameraSource) {
+status_t GonkRecorder::setupCameraSource(
+        sp<GonkCameraSource> *cameraSource) {
     status_t err = OK;
     if ((err = checkVideoEncoderCapabilities()) != OK) {
         return err;
@@ -1416,26 +1164,15 @@
     Size videoSize;
     videoSize.width = mVideoWidth;
     videoSize.height = mVideoHeight;
-    if (mCaptureTimeLapse) {
-        mCameraSourceTimeLapse = CameraSourceTimeLapse::CreateFromCamera(
-                mCamera, mCameraProxy, mCameraId,
-                videoSize, mFrameRate, mPreviewSurface,
-                mTimeBetweenTimeLapseFrameCaptureUs);
-        *cameraSource = mCameraSourceTimeLapse;
-    } else {
-
-        bool useMeta = true;
-        char value[PROPERTY_VALUE_MAX];
-        if (property_get("debug.camcorder.disablemeta", value, NULL) &&
+    bool useMeta = true;
+    char value[PROPERTY_VALUE_MAX];
+    if (property_get("debug.camcorder.disablemeta", value, NULL) &&
             atoi(value)) {
-            useMeta = false;
-        }
-        *cameraSource = CameraSource::CreateFromCamera(
-                mCamera, mCameraProxy, mCameraId, videoSize, mFrameRate,
-                mPreviewSurface, useMeta);
+      useMeta = false;
     }
-    mCamera.clear();
-    mCameraProxy.clear();
+
+    *cameraSource = GonkCameraSource::Create(
+                mCameraHandle, videoSize, mFrameRate, useMeta);
     if (*cameraSource == NULL) {
         return UNKNOWN_ERROR;
     }
@@ -1465,7 +1202,7 @@
     return OK;
 }
 
-status_t StagefrightRecorder::setupVideoEncoder(
+status_t GonkRecorder::setupVideoEncoder(
         sp<MediaSource> cameraSource,
         int32_t videoBitRate,
         sp<MediaSource> *source) {
@@ -1501,10 +1238,7 @@
     CHECK(meta->findInt32(kKeyStride, &stride));
     CHECK(meta->findInt32(kKeySliceHeight, &sliceHeight));
     CHECK(meta->findInt32(kKeyColorFormat, &colorFormat));
-    hfr = 0;
-    if (!meta->findInt32(kKeyHFR, &hfr)) {
-        LOGW("hfr not found, default to 0");
-    }
+    CHECK(meta->findInt32(kKeyHFR, &hfr));
 
     if(hfr) {
       mMaxFileDurationUs = mMaxFileDurationUs * (hfr/mFrameRate);
@@ -1598,30 +1332,17 @@
         enc_meta->setInt32(kKey3D, is3D);
     }
 
-    OMXClient client;
-    CHECK_EQ(client.connect(), OK);
-
     uint32_t encoder_flags = 0;
     if (mIsMetaDataStoredInVideoBuffers) {
         LOGW("Camera source supports metadata mode, create OMXCodec for metadata");
         encoder_flags |= OMXCodec::kHardwareCodecsOnly;
         encoder_flags |= OMXCodec::kStoreMetaDataInVideoBuffers;
-        if (property_get("ro.board.platform", value, "0")
-            && (!strncmp(value, "msm7627", sizeof("msm7627") - 1))) {
-            LOGW("msm7627 family of chipsets supports, only one buffer at a time");
-            encoder_flags |= OMXCodec::kOnlySubmitOneInputBufferAtOneTime;
-        }
-    }
-
-    // Do not wait for all the input buffers to become available.
-    // This give timelapse video recording faster response in
-    // receiving output from video encoder component.
-    if (mCaptureTimeLapse) {
         encoder_flags |= OMXCodec::kOnlySubmitOneInputBufferAtOneTime;
     }
 
     sp<MediaSource> encoder = OMXCodec::Create(
-            client.interface(), enc_meta,
+            GetOMX(),
+            enc_meta,
             true /* createEncoder */, cameraSource,
             NULL, encoder_flags);
     if (encoder == NULL) {
@@ -1638,7 +1359,7 @@
     return OK;
 }
 
-status_t StagefrightRecorder::setupAudioEncoder(const sp<MediaWriter>& writer) {
+status_t GonkRecorder::setupAudioEncoder(const sp<MediaWriter>& writer) {
     status_t status = BAD_VALUE;
     if (OK != (status = checkAudioEncoderCapabilities())) {
         return status;
@@ -1664,7 +1385,7 @@
     return OK;
 }
 
-status_t StagefrightRecorder::setupMPEG4Recording(
+status_t GonkRecorder::setupMPEG4Recording(
         int outputFd,
         int32_t videoWidth, int32_t videoHeight,
         int32_t videoBitRate,
@@ -1696,7 +1417,7 @@
     // Audio source is added at the end if it exists.
     // This help make sure that the "recoding" sound is suppressed for
     // camcorder applications in the recorded files.
-    if (!mCaptureTimeLapse && (mAudioSource != AUDIO_SOURCE_CNT)) {
+    if (mAudioSource != AUDIO_SOURCE_CNT) {
         err = setupAudioEncoder(writer);
         if (err != OK) return err;
         *totalBitRate += mAudioBitRate;
@@ -1728,7 +1449,7 @@
     return OK;
 }
 
-void StagefrightRecorder::setupMPEG4MetaData(int64_t startTimeUs, int32_t totalBitRate,
+void GonkRecorder::setupMPEG4MetaData(int64_t startTimeUs, int32_t totalBitRate,
         sp<MetaData> *meta) {
     (*meta)->setInt64(kKeyTime, startTimeUs);
     (*meta)->setInt32(kKeyFileType, mOutputFormat);
@@ -1752,7 +1473,7 @@
     }
 }
 
-status_t StagefrightRecorder::startMPEG4Recording() {
+status_t GonkRecorder::startMPEG4Recording() {
     int32_t totalBitRate;
     status_t err = setupMPEG4Recording(
             mOutputFd, mVideoWidth, mVideoHeight,
@@ -1761,7 +1482,14 @@
         return err;
     }
 
-    int64_t startTimeUs = systemTime() / 1000;
+    //systemTime() doesn't give correct time because
+    //HAVE_POSIX_CLOCKS is not defined for utils/Timers.cpp
+    //so, using clock_gettime directly
+#include <time.h>
+    struct timespec t;
+    clock_gettime(CLOCK_MONOTONIC, &t);
+    int64_t startTimeUs = int64_t(t.tv_sec)*1000000000LL + t.tv_nsec;
+    startTimeUs = startTimeUs / 1000;
     sp<MetaData> meta = new MetaData;
     setupMPEG4MetaData(startTimeUs, totalBitRate, &meta);
 
@@ -1773,7 +1501,7 @@
     return OK;
 }
 
-status_t StagefrightRecorder::pause() {
+status_t GonkRecorder::pause() {
     LOGV("pause");
     if (mWriter == NULL) {
         return UNKNOWN_ERROR;
@@ -1782,31 +1510,16 @@
 
     if (mStarted) {
         mStarted = false;
-
-        uint32_t params = 0;
-        if (mAudioSource != AUDIO_SOURCE_CNT) {
-            params |= IMediaPlayerService::kBatteryDataTrackAudio;
-        }
-        if (mVideoSource != VIDEO_SOURCE_LIST_END) {
-            params |= IMediaPlayerService::kBatteryDataTrackVideo;
-        }
-
-        addBatteryData(params);
     }
 
 
     return OK;
 }
 
-status_t StagefrightRecorder::stop() {
+status_t GonkRecorder::stop() {
     LOGV("stop");
     status_t err = OK;
 
-    if (mCaptureTimeLapse && mCameraSourceTimeLapse != NULL) {
-        mCameraSourceTimeLapse->startQuickReadReturns();
-        mCameraSourceTimeLapse = NULL;
-    }
-
     if (mWriter != NULL) {
         err = mWriter->stop();
         mWriter.clear();
@@ -1819,30 +1532,20 @@
 
     if (mStarted) {
         mStarted = false;
-
-        uint32_t params = 0;
-        if (mAudioSource != AUDIO_SOURCE_CNT) {
-            params |= IMediaPlayerService::kBatteryDataTrackAudio;
-        }
-        if (mVideoSource != VIDEO_SOURCE_LIST_END) {
-            params |= IMediaPlayerService::kBatteryDataTrackVideo;
-        }
-
-        addBatteryData(params);
     }
 
 
     return err;
 }
 
-status_t StagefrightRecorder::close() {
+status_t GonkRecorder::close() {
     LOGV("close");
     stop();
 
     return OK;
 }
 
-status_t StagefrightRecorder::reset() {
+status_t GonkRecorder::reset() {
     LOGV("reset");
     stop();
 
@@ -1858,9 +1561,9 @@
     mVideoHeight   = 144;
     mFrameRate     = -1;
     mVideoBitRate  = 192000;
-    mSampleRate    = 0;
-    mAudioChannels = 0;
-    mAudioBitRate  = 0;
+    mSampleRate    = 8000;
+    mAudioChannels = 1;
+    mAudioBitRate  = 12200;
     mInterleaveDurationUs = 0;
     mIFramesIntervalSec = 2;
     mAudioSourceNode = 0;
@@ -1875,9 +1578,6 @@
     mMaxFileDurationUs = 0;
     mMaxFileSizeBytes = 0;
     mTrackEveryTimeDurationUs = 0;
-    mCaptureTimeLapse = false;
-    mTimeBetweenTimeLapseFrameCaptureUs = -1;
-    mCameraSourceTimeLapse = NULL;
     mIsMetaDataStoredInVideoBuffers = false;
     mEncoderProfiles = MediaProfiles::getInstance();
     mRotationDegrees = 0;
@@ -1885,6 +1585,11 @@
     mLongitudex10000 = -3600000;
 
     mOutputFd = -1;
+    mCameraHandle = -1;
+    //TODO: May need to register a listener eventually
+    //if someone is interested in recorder events for now
+    //default to no listener registered
+    mListener = NULL;
 
     // Disable Audio Encoding
     char value[PROPERTY_VALUE_MAX];
@@ -1894,7 +1599,7 @@
     return OK;
 }
 
-status_t StagefrightRecorder::getMaxAmplitude(int *max) {
+status_t GonkRecorder::getMaxAmplitude(int *max) {
     LOGV("getMaxAmplitude");
 
     if (max == NULL) {
@@ -1911,7 +1616,7 @@
     return OK;
 }
 
-status_t StagefrightRecorder::dump(
+status_t GonkRecorder::dump(
         int fd, const Vector<String16>& args) const {
     LOGV("dump");
     const size_t SIZE = 256;
@@ -1958,6 +1663,8 @@
     result.append(buffer);
     snprintf(buffer, SIZE, "     Camera Id: %d\n", mCameraId);
     result.append(buffer);
+    snprintf(buffer, SIZE, "     Camera Handle: %d\n", mCameraHandle);
+    result.append(buffer);
     snprintf(buffer, SIZE, "     Start time offset (ms): %d\n", mStartTimeOffsetMs);
     result.append(buffer);
     snprintf(buffer, SIZE, "     Encoder: %d\n", mVideoEncoder);
@@ -1978,45 +1685,12 @@
     return OK;
 }
 
-status_t StagefrightRecorder::startExtendedRecording() {
-    CHECK(mOutputFormat == OUTPUT_FORMAT_QCP);
-
-    if (mSampleRate != 8000) {
-        LOGE("Invalid sampling rate %d used for recording",
-             mSampleRate);
-        return BAD_VALUE;
-    }
-    if (mAudioChannels != 1) {
-        LOGE("Invalid number of audio channels %d used for recording",
-                mAudioChannels);
-        return BAD_VALUE;
-    }
-
-    if (mAudioSource >= AUDIO_SOURCE_CNT) {
-        LOGE("Invalid audio source: %d", mAudioSource);
-        return BAD_VALUE;
-    }
-
-    sp<MediaSource> audioEncoder = createAudioSource();
-
-    if (audioEncoder == NULL) {
-        LOGE("AudioEncoder NULL");
-        return UNKNOWN_ERROR;
-    }
-
-    mWriter = new ExtendedWriter(dup(mOutputFd));
-    mWriter->addSource(audioEncoder);
-
-    if (mMaxFileDurationUs != 0) {
-        mWriter->setMaxFileDuration(mMaxFileDurationUs);
-    }
-    if (mMaxFileSizeBytes != 0) {
-        mWriter->setMaxFileSize(mMaxFileSizeBytes);
-    }
-    mWriter->setListener(mListener);
-    mWriter->start();
-
-    return OK;
+status_t GonkRecorder::setCameraHandle(int32_t handle) {
+  if (handle < 0) {
+    return BAD_VALUE;
+  }
+  mCameraHandle = handle;
+  return OK;
 }
 
 }  // namespace android
diff --git a/GonkRecorder.h b/GonkRecorder.h
index dba6110..fa948af 100644
--- a/GonkRecorder.h
+++ b/GonkRecorder.h
@@ -14,11 +14,11 @@
  * limitations under the License.
  */
 
-#ifndef STAGEFRIGHT_RECORDER_H_
+#ifndef GONK_RECORDER_H_
 
-#define STAGEFRIGHT_RECORDER_H_
+#define GONK_RECORDER_H_
 
-#include <media/MediaRecorderBase.h>
+#include <media/mediarecorder.h>
 #include <camera/CameraParameters.h>
 #include <utils/String8.h>
 
@@ -26,21 +26,16 @@
 
 namespace android {
 
-class Camera;
-class ICameraRecordingProxy;
-class CameraSource;
-class CameraSourceTimeLapse;
+class GonkCameraSource;
 struct MediaSource;
 struct MediaWriter;
 class MetaData;
 struct AudioSource;
 class MediaProfiles;
-class ISurfaceTexture;
-class SurfaceMediaSource;
 
-struct StagefrightRecorder : public MediaRecorderBase {
-    StagefrightRecorder();
-    virtual ~StagefrightRecorder();
+struct GonkRecorder {
+    GonkRecorder();
+    virtual ~GonkRecorder();
 
     virtual status_t init();
     virtual status_t setAudioSource(audio_source_t as);
@@ -50,11 +45,10 @@
     virtual status_t setVideoEncoder(video_encoder ve);
     virtual status_t setVideoSize(int width, int height);
     virtual status_t setVideoFrameRate(int frames_per_second);
-    virtual status_t setCamera(const sp<ICamera>& camera, const sp<ICameraRecordingProxy>& proxy);
-    virtual status_t setPreviewSurface(const sp<Surface>& surface);
     virtual status_t setOutputFile(const char *path);
     virtual status_t setOutputFile(int fd, int64_t offset, int64_t length);
     virtual status_t setParameters(const String8& params);
+    virtual status_t setCameraHandle(int32_t handle);
     virtual status_t setListener(const sp<IMediaRecorderClient>& listener);
     virtual status_t prepare();
     virtual status_t start();
@@ -65,12 +59,8 @@
     virtual status_t getMaxAmplitude(int *max);
     virtual status_t dump(int fd, const Vector<String16>& args) const;
     // Querying a SurfaceMediaSourcer
-    virtual sp<ISurfaceTexture> querySurfaceMediaSource() const;
 
 private:
-    sp<ICamera> mCamera;
-    sp<ICameraRecordingProxy> mCameraProxy;
-    sp<Surface> mPreviewSurface;
     sp<IMediaRecorderClient> mListener;
     sp<MediaWriter> mWriter;
     int mOutputFd;
@@ -104,11 +94,6 @@
     int32_t mLongitudex10000;
     int32_t mStartTimeOffsetMs;
 
-    bool mCaptureTimeLapse;
-    int64_t mTimeBetweenTimeLapseFrameCaptureUs;
-    sp<CameraSourceTimeLapse> mCameraSourceTimeLapse;
-
-
     String8 mParams;
 
     bool mIsMetaDataStoredInVideoBuffers;
@@ -119,8 +104,8 @@
     // An <ISurfaceTexture> pointer
     // will be sent to the client side using which the
     // frame buffers will be queued and dequeued
-    sp<SurfaceMediaSource> mSurfaceMediaSource;
     bool mDisableAudio;
+    int32_t mCameraHandle;
 
     status_t setupMPEG4Recording(
         int outputFd,
@@ -132,10 +117,7 @@
         sp<MetaData> *meta);
     status_t startMPEG4Recording();
     status_t startAMRRecording();
-    status_t startFMA2DPWriter();
-    status_t startAACRecording();
     status_t startRawAudioRecording();
-    status_t startRTPRecording();
     status_t startMPEG2TSRecording();
     sp<MediaSource> createAudioSource();
     status_t checkVideoEncoderCapabilities();
@@ -144,9 +126,8 @@
     // source (CameraSource or SurfaceMediaSource)
     // depending on the videosource type
     status_t setupMediaSource(sp<MediaSource> *mediaSource);
-    status_t setupCameraSource(sp<CameraSource> *cameraSource);
+    status_t setupCameraSource(sp<GonkCameraSource> *cameraSource);
     // setup the surfacemediasource for the encoder
-    status_t setupSurfaceMediaSource();
 
     status_t setupAudioEncoder(const sp<MediaWriter>& writer);
     status_t setupVideoEncoder(
@@ -160,8 +141,6 @@
     status_t setParamAudioNumberOfChannels(int32_t channles);
     status_t setParamAudioSamplingRate(int32_t sampleRate);
     status_t setParamAudioTimeScale(int32_t timeScale);
-    status_t setParamTimeLapseEnable(int32_t timeLapseEnable);
-    status_t setParamTimeBetweenTimeLapseFrameCapture(int64_t timeUs);
     status_t setParamVideoEncodingBitRate(int32_t bitRate);
     status_t setParamVideoIFramesInterval(int32_t seconds);
     status_t setParamVideoEncoderProfile(int32_t profile);
@@ -186,14 +165,10 @@
     void clipNumberOfAudioChannels();
     void setDefaultProfileIfNecessary();
 
-
-    StagefrightRecorder(const StagefrightRecorder &);
-    StagefrightRecorder &operator=(const StagefrightRecorder &);
-
-    /* extension */
-    status_t startExtendedRecording();
+    GonkRecorder(const GonkRecorder &);
+    GonkRecorder &operator=(const GonkRecorder &);
 };
 
 }  // namespace android
 
-#endif  // STAGEFRIGHT_RECORDER_H_
+#endif  // GONK_RECORDER_H_