aboutsummaryrefslogtreecommitdiffstats
path: root/meta-ivi-demo/recipes-multimedia/audiomanager/audiomanager/0001-Porting-Pulse-Routing-Interface-from-AM-v1.x-to-AM-v.patch
blob: d01854d274ad08b9268e3b8a634df706317dc77d (plain)
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
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
From 68c0d6ef9b1070505c1664fe567948a9f661da28 Mon Sep 17 00:00:00 2001
From: Adrian Scarlat <adrian.scarlat@windriver.com>
Date: Thu, 21 Aug 2014 14:52:46 +0300
Subject: [PATCH] Porting Pulse Routing Interface from AM v1.x to AM v3.0

This Routing Interface is needed for any application that will
be developed on top of AM and will use PulseAudio Sound Server
to control the sources and sinks present on the system. It must
be loaded by AM;

The interface can be built by supplying cmake with the -DWITH_PULSE_ROUTING_PLUGIN=ON;
There are two configuration files that are use for the moment:
  1. libPluginRoutingInterfacePULSE.conf - configuration file for
     Pulse Routing Plugin; it will be loaded at runtime by the Pulse Routing Interface;
  2. genivi-amgr.pa - configuration file for PulseAudio;
     It must be used to start PulseAudio daemon on the system;

Changed files:
  CMakeLists.txt

Added new folders:
  PluginRoutingInterfacePulse/

Added new files:
  PluginRoutingInterfacePulse/CMakeLists.txt
  PluginRoutingInterfacePulse/README
  PluginRoutingInterfacePulse/cmake/FindDBUS.cmake
  PluginRoutingInterfacePulse/data/asound.conf
  PluginRoutingInterfacePulse/data/client.conf
  PluginRoutingInterfacePulse/data/daemon.conf
  PluginRoutingInterfacePulse/data/genivi-amgr.pa
  PluginRoutingInterfacePulse/data/libPluginRoutingInterfacePULSE.conf
  PluginRoutingInterfacePulse/include/RoutingSenderMainloopPULSE.h
  PluginRoutingInterfacePulse/include/RoutingSenderPULSE.h
  PluginRoutingInterfacePulse/src/RoutingSenderMainloopPULSE.cpp
  PluginRoutingInterfacePulse/src/RoutingSenderPULSE.cpp

Signed-off-by: Adrian Scarlat <adrian.scarlat@windriver.com>
---
 CMakeLists.txt                                     |   24 +-
 PluginRoutingInterfacePulse/CMakeLists.txt         |  120 +++
 PluginRoutingInterfacePulse/README                 |   11 +
 PluginRoutingInterfacePulse/cmake/FindDBUS.cmake   |   38 +
 PluginRoutingInterfacePulse/data/asound.conf       |   35 +
 PluginRoutingInterfacePulse/data/client.conf       |   22 +
 PluginRoutingInterfacePulse/data/daemon.conf       |   44 +
 PluginRoutingInterfacePulse/data/genivi-amgr.pa    |   68 ++
 .../data/libPluginRoutingInterfacePULSE.conf       |   59 ++
 .../include/RoutingSenderMainloopPULSE.h           |   97 ++
 .../include/RoutingSenderPULSE.h                   |  131 +++
 .../src/RoutingSenderMainloopPULSE.cpp             |  610 +++++++++++++
 .../src/RoutingSenderPULSE.cpp                     |  923 ++++++++++++++++++++
 13 files changed, 2176 insertions(+), 6 deletions(-)
 create mode 100644 PluginRoutingInterfacePulse/CMakeLists.txt
 create mode 100644 PluginRoutingInterfacePulse/README
 create mode 100644 PluginRoutingInterfacePulse/cmake/FindDBUS.cmake
 create mode 100644 PluginRoutingInterfacePulse/data/asound.conf
 create mode 100644 PluginRoutingInterfacePulse/data/client.conf
 create mode 100644 PluginRoutingInterfacePulse/data/daemon.conf
 create mode 100644 PluginRoutingInterfacePulse/data/genivi-amgr.pa
 create mode 100644 PluginRoutingInterfacePulse/data/libPluginRoutingInterfacePULSE.conf
 create mode 100644 PluginRoutingInterfacePulse/include/RoutingSenderMainloopPULSE.h
 create mode 100644 PluginRoutingInterfacePulse/include/RoutingSenderPULSE.h
 create mode 100644 PluginRoutingInterfacePulse/src/RoutingSenderMainloopPULSE.cpp
 create mode 100644 PluginRoutingInterfacePulse/src/RoutingSenderPULSE.cpp

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 3e70e4f..48e7ae2 100755
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -95,7 +95,15 @@ OPTION ( WITH_NSM
  OPTION ( WITH_DATABASE_STORAGE
     "build with sqlite as in memory storage" OFF)
 
+OPTION( WITH_PULSE_ROUTING_PLUGIN
+    "Enable PULSE Audio routing plugin interface" OFF )
+
 SET (WITH_COMMON_API_GEN ON CACHE INTERNAL "hide this!" FORCE)
+
+IF (WITH_PULSE_ROUTING_PLUGIN)
+    SET (WITH_DBUS_WRAPPER ON CACHE INTERNAL "hide this!" FORCE)
+    SET (WITH_CAPI_WRAPPER OFF CACHE INTERNAL "hide this!" FORCE)
+ENDIF (WITH_PULSE_ROUTING_PLUGIN)
  
 IF (WITH_ENABLED_IPC STREQUAL "DBUS")
     SET (WITH_DBUS_WRAPPER ON CACHE INTERNAL "hide this!" FORCE)
@@ -239,12 +247,16 @@ if(WITH_PLUGIN_COMMAND)
 endif(WITH_PLUGIN_COMMAND)
 
 if(WITH_PLUGIN_ROUTING)
-	add_subdirectory (PluginRoutingInterfaceAsync)
-    if(WITH_DBUS_WRAPPER)
-	    add_subdirectory (PluginRoutingInterfaceDbus)
-	elseif(WITH_CAPI_WRAPPER)  	    
-    	add_subdirectory (PluginRoutingInterfaceCAPI)    
-	endif()    
+    if (WITH_PULSE_ROUTING_PLUGIN)
+        add_subdirectory (PluginRoutingInterfacePulse)
+    else ()
+        add_subdirectory (PluginRoutingInterfaceAsync)
+        if(WITH_DBUS_WRAPPER)
+            add_subdirectory (PluginRoutingInterfaceDbus)
+        elseif(WITH_CAPI_WRAPPER)
+            add_subdirectory (PluginRoutingInterfaceCAPI)
+        endif()
+    endif()
 endif(WITH_PLUGIN_ROUTING)
 
 if(WITH_PLUGIN_CONTROL)
diff --git a/PluginRoutingInterfacePulse/CMakeLists.txt b/PluginRoutingInterfacePulse/CMakeLists.txt
new file mode 100644
index 0000000..b889f6a
--- /dev/null
+++ b/PluginRoutingInterfacePulse/CMakeLists.txt
@@ -0,0 +1,120 @@
+############################################################################
+# SPDX license identifier: MPL-2.0
+#
+# Copyright (C) 2012-2014, Wind River Systems
+# Copyright (C) 2014, GENIVI Alliance
+#
+# This file is part of Pulse Audio Interface Routing Plugin.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License (MPL), v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+# For further information see http://www.genivi.org/.
+#
+# List of changes:
+#
+# 21.08.2014, Adrian Scarlat, First version of the code;
+#                             Porting code from AM ver1.x to AM ver3.0;
+#                             Added Copyright and License information;
+############################################################################
+
+cmake_minimum_required(VERSION 2.6)
+
+PROJECT(PluginRoutingInterfacePULSE)
+
+set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -rdynamic")
+set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g")
+FILE(GLOB pulseConf "${CMAKE_CURRENT_SOURCE_DIR}/README*")
+FIND_PACKAGE(PkgConfig)
+
+OPTION( WITH_DOCUMENTATION
+	"Build together with Doxygen Documentation" OFF )
+
+SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/cmake)
+SET(PLUGINS_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/bin/plugins)
+set(LIBRARY_OUTPUT_PATH ${PLUGINS_OUTPUT_PATH}/routing)
+set(DOC_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/doc/RoutingPlugin)
+set(INCLUDES_FOLDER "include")
+SET(LIB_INSTALL_SUFFIX "audioManager")
+
+FIND_PACKAGE(DBUS REQUIRED)
+FIND_PATH(AUDIO_INCLUDE_FOLDER audiomanagertypes.h /usr/include)
+
+if(DEFINED AUDIO_INCLUDE_FOLDER)
+	message(STATUS "Found AudioManager include: ${AUDIO_INCLUDE_FOLDER}")
+else(DEFINED AUDIO_INCLUDE_FOLDER)
+	message(STATUS "Did not found AudioManager include!")
+endif(DEFINED AUDIO_INCLUDE_FOLDER)
+
+FILE(READ "${AUDIO_INCLUDE_FOLDER}/routing/IAmRoutingSend.h" VERSION_BUFFER LIMIT 6000)
+STRING(REGEX MATCH "RoutingSendVersion*.[^0-9]*[0-9]" LIB_INTERFACE_VERSION_STRING ${VERSION_BUFFER})
+STRING(REGEX REPLACE "[^0-9]" "" LIB_INTERFACE_VERSION ${LIB_INTERFACE_VERSION_STRING})
+MESSAGE(STATUS "Building against routing interface version ${LIB_INTERFACE_VERSION}")
+
+SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/cmake)
+FIND_PACKAGE(DBUS REQUIRED)
+
+INCLUDE_DIRECTORIES(
+	${CMAKE_SOURCE_DIR} 
+ 	${CMAKE_CURRENT_BINARY_DIR}
+ 	${DBUS_INCLUDE_DIR}
+	${DBUS_ARCH_INCLUDE_DIR}
+	${AUDIO_INCLUDE_FOLDER}
+	${INCLUDES_FOLDER}
+)
+
+# all source files go here
+file(GLOB PLUGINDBUS_SRCS_CXX "src/*.cpp")
+
+add_library(PluginRoutingInterfacePULSE SHARED ${PLUGINDBUS_SRCS_CXX})
+
+TARGET_LINK_LIBRARIES(PluginRoutingInterfacePULSE 
+    pulse
+    ${DLT_LIBRARIES}
+    ${DBUS_LIBRARY}
+)
+
+IF(WITH_DOCUMENTATION)
+	file(MAKE_DIRECTORY ${DOC_OUTPUT_PATH})
+	configure_file(${DOXY_FILE}  ${DOC_OUTPUT_PATH}/Doxyfile  @ONLY IMMEDIATE)
+  	add_custom_target (PluginRoutingInterfacePULSEDocs ALL 
+  		COMMAND ${DOXYGEN_EXECUTABLE} ${DOC_OUTPUT_PATH}/Doxyfile WORKING_DIRECTORY ${DOC_OUTPUT_PATH}
+  		SOURCES ${PROJECT_BINARY_DIR} ${DOC_OUTPUT_PATH}/Doxyfile
+	)
+ENDIF(WITH_DOCUMENTATION)
+
+INSTALL(TARGETS PluginRoutingInterfacePULSE 
+        DESTINATION "lib/${LIB_INSTALL_SUFFIX}/routing"
+        PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ GROUP_EXECUTE GROUP_READ WORLD_EXECUTE WORLD_READ
+        COMPONENT sampleplugins
+)
+
+INSTALL(FILES data/libPluginRoutingInterfacePULSE.conf
+        DESTINATION "lib/${LIB_INSTALL_SUFFIX}/routing"
+        PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ GROUP_EXECUTE GROUP_READ WORLD_EXECUTE WORLD_READ
+        COMPONENT sampleplugins
+)
+INSTALL(FILES data/client.conf
+        DESTINATION "lib/${LIB_INSTALL_SUFFIX}/routing"
+        PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ GROUP_EXECUTE GROUP_READ WORLD_EXECUTE WORLD_READ
+        COMPONENT sampleplugins
+)
+INSTALL(FILES data/daemon.conf
+        DESTINATION "lib/${LIB_INSTALL_SUFFIX}/routing"
+        PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ GROUP_EXECUTE GROUP_READ WORLD_EXECUTE WORLD_READ
+        COMPONENT sampleplugins
+)
+INSTALL(FILES data/asound.conf
+        DESTINATION "lib/${LIB_INSTALL_SUFFIX}/routing"
+        PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ GROUP_EXECUTE GROUP_READ WORLD_EXECUTE WORLD_READ
+        COMPONENT sampleplugins
+)
+INSTALL(FILES data/genivi-amgr.pa
+        DESTINATION "lib/${LIB_INSTALL_SUFFIX}/routing"
+        PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ GROUP_EXECUTE GROUP_READ WORLD_EXECUTE WORLD_READ
+        COMPONENT sampleplugins
+)
+
+CONFIGURE_FILE( ${CMAKE_SOURCE_DIR}/PluginRoutingInterfacePulse/data/libPluginRoutingInterfacePULSE.conf ${PLUGINS_OUTPUT_PATH}/routing/libPluginRoutingInterfacePULSE.conf )
+CONFIGURE_FILE( ${CMAKE_SOURCE_DIR}/PluginRoutingInterfacePulse/data/genivi-amgr.pa ${PLUGINS_OUTPUT_PATH}/routing/genivi-amgr.pa )
diff --git a/PluginRoutingInterfacePulse/README b/PluginRoutingInterfacePulse/README
new file mode 100644
index 0000000..7c9b082
--- /dev/null
+++ b/PluginRoutingInterfacePulse/README
@@ -0,0 +1,11 @@
+Description of PluginRoutingInterfacePulse
+------------------------------------------
+- The PluginRoutingInterfacePulse is used by the AM PoC application to communicate with Pulse
+  present on the system on which the AM PoC application will be deployed;
+
+Build intstructions
+-------------------
+- To build the Pulse Routing Plugin pass the following option to CMake: -DWITH_PULSE_ROUTING_PLUGIN=ON
+
+
+
diff --git a/PluginRoutingInterfacePulse/cmake/FindDBUS.cmake b/PluginRoutingInterfacePulse/cmake/FindDBUS.cmake
new file mode 100644
index 0000000..9a24f18
--- /dev/null
+++ b/PluginRoutingInterfacePulse/cmake/FindDBUS.cmake
@@ -0,0 +1,38 @@
+############################################################################
+# SPDX license identifier: MPL-2.0
+#
+# Copyright (C) 2012-2014, Wind River Systems
+# Copyright (C) 2014, GENIVI Alliance
+#
+# This file is part of Pulse Audio Interface Routing Plugin.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License (MPL), v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+# For further information see http://www.genivi.org/.
+#
+# List of changes:
+#
+# 21.08.2014, Adrian Scarlat, First version of the code;
+#                             Porting code from AM ver1.x to AM ver3.0;
+#                             Added Copyright and License information;
+############################################################################
+
+FIND_PATH(DBUS_INCLUDE_DIR dbus/dbus.h /usr/include/dbus-1.0)
+FIND_PATH(DBUS_ARCH_INCLUDE_DIR dbus/dbus-arch-deps.h /usr/lib/dbus-1.0/include /usr/lib/*/dbus-1.0/include )
+FIND_LIBRARY(DBUS_LIBRARY NAMES dbus-1 PATHS /lib)
+
+SET( DBUS_FOUND "NO" )
+IF(DBUS_LIBRARY)
+    SET( DBUS_FOUND "YES" )
+    message(STATUS "Found DBUS libs: ${DBUS_LIBRARY}")
+    message(STATUS "Found DBUS include: ${DBUS_INCLUDE_DIR}")
+    message(STATUS "Found DBUS arch dependent include: ${DBUS_ARCH_INCLUDE_DIR}")
+ENDIF(DBUS_LIBRARY)
+
+MARK_AS_ADVANCED(
+  DBUS_INCLUDE_DIR
+  DBUS_ARCH_INCLUDE_DIR
+  DBUS_LIBRARY
+)
diff --git a/PluginRoutingInterfacePulse/data/asound.conf b/PluginRoutingInterfacePulse/data/asound.conf
new file mode 100644
index 0000000..e17f837
--- /dev/null
+++ b/PluginRoutingInterfacePulse/data/asound.conf
@@ -0,0 +1,35 @@
+############################################################################
+# SPDX license identifier: MPL-2.0
+#
+# Copyright (C) 2012-2014, Wind River Systems
+# Copyright (C) 2014, GENIVI Alliance
+#
+# This file is part of Pulse Audio Interface Routing Plugin.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License (MPL), v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+# For further information see http://www.genivi.org/.
+#
+# List of changes:
+#
+# 21.08.2014, Adrian Scarlat, First version of the code;
+#                             Porting code from AM ver1.x to AM ver3.0;
+#                             Added Copyright and License information;
+############################################################################
+pcm.pulse {
+  type pulse
+}
+
+ctl.pulse {
+  type pulse
+}
+
+pcm.!default {
+  type pulse
+}
+
+ctl.!default {
+  type pulse
+}
diff --git a/PluginRoutingInterfacePulse/data/client.conf b/PluginRoutingInterfacePulse/data/client.conf
new file mode 100644
index 0000000..c607b8d
--- /dev/null
+++ b/PluginRoutingInterfacePulse/data/client.conf
@@ -0,0 +1,22 @@
+############################################################################
+# SPDX license identifier: MPL-2.0
+#
+# Copyright (C) 2012-2014, Wind River Systems
+# Copyright (C) 2014, GENIVI Alliance
+#
+# This file is part of Pulse Audio Interface Routing Plugin.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License (MPL), v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+# For further information see http://www.genivi.org/.
+#
+# List of changes:
+#
+# 21.08.2014, Adrian Scarlat, First version of the code;
+#                             Porting code from AM ver1.x to AM ver3.0;
+#                             Added Copyright and License information;
+############################################################################
+
+default-server = 127.0.0.1
diff --git a/PluginRoutingInterfacePulse/data/daemon.conf b/PluginRoutingInterfacePulse/data/daemon.conf
new file mode 100644
index 0000000..0a291d4
--- /dev/null
+++ b/PluginRoutingInterfacePulse/data/daemon.conf
@@ -0,0 +1,44 @@
+# SPDX license identifier: LGPL-2.0
+#
+# This file is part of PulseAudio.
+#
+# PulseAudio is free software; you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# PulseAudio is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public License
+# along with PulseAudio; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+# USA.
+
+## Configuration file for the PulseAudio daemon. See pulse-daemon.conf(5) for
+## more information. Default values are commented out.  Use either ; or # for
+## commenting.
+#
+# For further information see http://www.genivi.org/.
+#
+# List of changes:
+#
+# 21.08.2014, Adrian Scarlat, First version of the code;
+#                             Porting code from AM ver1.x to AM ver3.0;
+############################################################################
+enable-shm=yes
+shm-size-bytes=8388608 #8MB # setting this 0 will use the system-default, usually 64 MiB
+exit-idle-time=-1
+high-priority=yes
+nice-level=-11
+realtime-scheduling=yes
+realtime-priority=5
+resample-method=trivial
+flat-volumes=no
+default-sample-format = s16le
+default-sample-rate = 44100
+default-sample-channels = 2
+default-fragment-size-msec = 3
+default-fragments = 8
diff --git a/PluginRoutingInterfacePulse/data/genivi-amgr.pa b/PluginRoutingInterfacePulse/data/genivi-amgr.pa
new file mode 100644
index 0000000..596ec19
--- /dev/null
+++ b/PluginRoutingInterfacePulse/data/genivi-amgr.pa
@@ -0,0 +1,68 @@
+############################################################################
+# SPDX license identifier: MPL-2.0
+#
+# Copyright (C) 2012-2014, Wind River Systems
+# Copyright (C) 2014, GENIVI Alliance
+#
+# This file is part of Pulse Audio Interface Routing Plugin.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License (MPL), v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+# For further information see http://www.genivi.org/.
+#
+# List of changes:
+#
+# 21.08.2014, Adrian Scarlat, First version of the code;
+#                             Porting code from AM ver1.x to AM ver3.0;
+#                             Added Copyright and License information;
+############################################################################
+.nofail
+
+.fail
+
+### Automatically restore the volume of streams and devices
+load-module module-device-restore
+load-module module-stream-restore
+load-module module-card-restore
+
+### Automatically load driver modules depending on the hardware available
+.ifexists module-udev-detect.so
+load-module module-udev-detect
+.else
+### Use the static hardware detection module (for systems that lack udev support)
+load-module module-detect
+.endif
+
+### Load several protocols
+.ifexists module-esound-protocol-unix.so
+load-module module-esound-protocol-unix
+.endif
+load-module module-native-protocol-unix
+
+### Automatically restore the default sink/source when changed by the user
+### during runtime
+### NOTE: This should be loaded as early as possible so that subsequent modules
+### that look up the default sink/source get the right value
+load-module module-default-device-restore
+
+### Automatically move streams to the default sink if the sink they are
+### connected to dies, similar for sources
+load-module module-rescue-streams
+
+### Make sure we always have a sink around, even if it is a null sink.
+load-module module-always-sink
+
+### Modules to allow autoloading of filters (such as echo cancellation)
+### on demand. module-filter-heuristics tries to determine what filters
+### make sense, and module-filter-apply does the heavy-lifting of
+### loading modules and rerouting streams.
+load-module module-filter-heuristics
+load-module module-filter-apply
+
+#Make  the  specified  sink (identified by its symbolic name) the  default sink.
+set-default-sink 0
+# Make the specified source (identified by its symbolic name) the default source.
+set-default-source 0
+
diff --git a/PluginRoutingInterfacePulse/data/libPluginRoutingInterfacePULSE.conf b/PluginRoutingInterfacePulse/data/libPluginRoutingInterfacePULSE.conf
new file mode 100644
index 0000000..43fae53
--- /dev/null
+++ b/PluginRoutingInterfacePulse/data/libPluginRoutingInterfacePULSE.conf
@@ -0,0 +1,59 @@
+############################################################################
+# SPDX license identifier: MPL-2.0
+#
+# Copyright (C) 2012-2014, Wind River Systems
+# Copyright (C) 2014, GENIVI Alliance
+#
+# This file is part of Pulse Audio Interface Routing Plugin.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License (MPL), v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+# For further information see http://www.genivi.org/.
+#
+# List of changes:
+#
+# 21.08.2014, Adrian Scarlat, First version of the code;
+#                             Porting code from AM ver1.x to AM ver3.0;
+#                             Added Copyright and License information;
+############################################################################
+#
+# config line format:
+#
+# TYPE|PULSE TYPE|CLASS|NAME|PROPERTY_NAME|PROPERTY_VALUE
+#
+# TYPE="Source" or "Sink"
+#
+# PULSE_TYPE="Sink Input" or "Source" for TYPE="Source"
+# PULSE_TYPE="Source Output" or "Sink" for TYPE="Sink"
+#
+# NAME=Any string not containing separator |
+#
+# CLASS=Any string not containing separator | - name should be consistent with Controller config
+#
+# PROPERTY_NAME=a Pulse recognized element property, e.g. "application.process.binary" or "device.class"
+#               for PULSE_TYPE=Source or PULSE_TYPE=Sink, take a look ad device string
+# PROPERTY_VALUE=any string corresponding to the property value
+#
+# TODO: provide support for multiple attributes filtering
+# TODO: comment at eof is mandatory! this looks like a bug for the moment
+####################
+# Sources
+####################
+## Test purpose audio sources
+Source|Sink Input|Entertainment|Media player|application.process.binary|MediaServiceGlueLogic
+Source|Sink Input|Entertainment|Browser|application.process.binary|WebRenderingGlueLogic
+Source|Sink Input|Navigation|Navigation|application.name|Test AMGRv2 TTS
+## Real audio sources
+#Source|Sink Input|Entertainment|Browser|application.process.binary|PilotHMI
+#Source|Sink Input|Entertainment|Gst Launch command line player|application.process.binary|gst-launch-0.10
+#Source|Sink Input|Navigation|ALSA command line player|application.process.binary|aplay
+#Source|Sink Input|Entertainment|Microphone Loopback|media.icon_name|audio-input-microphone
+#Source|Source|Entertainment|Microphone|device.string|hw:0,1
+####################
+# Sinks
+####################
+Sink|Sink|HifiAudio|Alsa Primary|ievice.string|hw:0,1
+Sink|Sink|HifiAudio|Alsa Secondary|device.string|hw:0,0
+# !END
diff --git a/PluginRoutingInterfacePulse/include/RoutingSenderMainloopPULSE.h b/PluginRoutingInterfacePulse/include/RoutingSenderMainloopPULSE.h
new file mode 100644
index 0000000..ff0c1d8
--- /dev/null
+++ b/PluginRoutingInterfacePulse/include/RoutingSenderMainloopPULSE.h
@@ -0,0 +1,97 @@
+/**
+ * SPDX license identifier: MPL-2.0
+ *
+ * Copyright (C) 2011-2014, Wind River Systems
+ * Copyright (C) 2014, GENIVI Alliance
+ *
+ * This file is part of Pulse Audio Interface Routing Plugin.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License (MPL), v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * For further information see http://www.genivi.org/.
+ *
+ * List of changes:
+ *
+ * 21.08.2014, Adrian Scarlat, First version of the code;
+ *                             Porting code from AM ver1.x to AM ver3.0;
+ *                             Added Copyright and License information;
+ */
+
+#ifndef ROUTINGSENDERMAINLOPPPULSE_H_
+#define ROUTINGSENDERMAINLOPPPULSE_H_
+
+/* Defines */
+/* In PulseAudio the volume value range from 0 (silence) to 0x10000U=65536 ("maximum" sensible volume). */
+#define MAX_PULSE_VOLUME    (0x10000U)
+
+bool routing_sender_create_mainloop(void *thiz);
+
+void * routing_sender_start_mainloop(void *thiz);
+
+void routing_sender_get_sink_info_callback(
+        pa_context *c,
+        const pa_sink_info *i,
+        int is_last, void *thiz);
+
+void routing_sender_context_state_callback(pa_context *c, void *thiz);
+
+bool routing_sender_get_source_info(pa_context *c, void *thiz);
+
+void routing_sender_pa_event_callback(
+        pa_context *c,
+        pa_subscription_event_type_t t,
+        uint32_t idx, void *thiz);
+
+void routing_sender_get_sink_input_info_callback(
+        pa_context *c,
+        const pa_sink_input_info *i,
+        int eol,
+        void *thiz);
+
+void routing_sender_get_source_output_info_callback(
+        pa_context *c,
+        const pa_source_output_info *i,
+        int eol,
+        void *userdata);
+
+bool routing_sender_move_sink_input(
+        pa_context *c,
+        uint32_t sink_input_index,
+        uint32_t sink_index,
+        void *thiz);
+
+bool routing_sender_move_source_output(
+        pa_context *c,
+        uint32_t source_output_index,
+        uint32_t source_index,
+        void *thiz);
+
+bool routing_sender_sink_input_volume_ramp(
+        pa_context *c,
+        uint32_t sink_input_index,
+        uint32_t crt_volume,
+        uint32_t volume,
+        uint16_t ramp_time,
+        void *thiz);
+
+bool routing_sender_sink_input_volume(
+        pa_context *c,
+        uint32_t sink_input_index,
+        uint32_t volume,
+        void *thiz);
+
+bool routing_sender_sink_input_mute(
+        pa_context *c,
+        uint32_t sink_input_index,
+        bool mute,
+        void *thiz);
+
+bool routing_sender_sink_volume(
+        pa_context *c,
+        uint32_t sink_index,
+        uint32_t volume,
+        void *thiz);
+
+#endif
diff --git a/PluginRoutingInterfacePulse/include/RoutingSenderPULSE.h b/PluginRoutingInterfacePulse/include/RoutingSenderPULSE.h
new file mode 100644
index 0000000..0fc2197
--- /dev/null
+++ b/PluginRoutingInterfacePulse/include/RoutingSenderPULSE.h
@@ -0,0 +1,131 @@
+/**
+ * SPDX license identifier: MPL-2.0
+ *
+ * Copyright (C) 2011-2014, Wind River Systems
+ * Copyright (C) 2014, GENIVI Alliance
+ *
+ * This file is part of Pulse Audio Interface Routing Plugin.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License (MPL), v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * For further information see http://www.genivi.org/.
+ *
+ * List of changes:
+ *
+ * 21.08.2014, Adrian Scarlat, First version of the code;
+ *                             Porting code from AM ver1.x to AM ver3.0;
+ *                             Added Copyright and License information;
+ */
+
+#ifndef ROUTINGSENDERPULSE_H_
+#define ROUTINGSENDERPULSE_H_
+
+/* Includes */
+#include "routing/IAmRoutingSend.h"
+#include <signal.h>
+#include <string.h>
+#include <errno.h>
+#include <unistd.h>
+#include <assert.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <limits.h>
+#include <getopt.h>
+#include <locale.h>
+#include <map>
+#include <pulse/pulseaudio.h>
+
+using namespace am;
+
+struct RoutingSenderPULSEConnection
+{
+    am_connectionID_t   connectionID;
+    am_sourceID_t       sourceID;
+    am_sinkID_t         sinkID;
+    am_Handle_s         handle;
+    bool                pending;
+};
+
+
+struct RoutingSenderPULSESourceSinkConfig
+{
+    am_Source_s source;
+    am_Sink_s   sink;
+
+    std::string name;//e.g. {"gst-launch-0.10",  "mono", "aplay"};
+    std::string clazz;//e.g. {"Entertainment", "Navigation", "TTS"};
+    std::string propertyName;//e.g. {"application.process.binary", "application.process.binary",    "application.process.app"};
+    std::string propertyValue;//
+};
+
+
+/* Prototypes */
+class RoutingSenderPULSE : public IAmRoutingSend
+{
+public:
+    RoutingSenderPULSE(pa_context *p_paContext);
+    ~RoutingSenderPULSE();
+
+    am::am_Error_e startupInterface(am::IAmRoutingReceive* p_routingReceiver);
+    void setRoutingReady(uint16_t handle);
+    void setRoutingRundown(uint16_t handle);
+    am_Error_e asyncAbort(const am_Handle_s handle);
+    am_Error_e asyncConnect(const am_Handle_s handle, const am_connectionID_t connectionID, const am_sourceID_t sourceID, const am_sinkID_t sinkID, const am_CustomConnectionFormat_t connectionFormat);
+    am_Error_e asyncDisconnect(const am_Handle_s handle, const am_connectionID_t connectionID);
+    am_Error_e asyncSetSinkVolume(const am_Handle_s handle, const am_sinkID_t sinkID, const am_volume_t volume, const am_CustomRampType_t ramp, const am_time_t time);
+    am_Error_e asyncSetSourceVolume(const am_Handle_s handle, const am_sourceID_t sourceID, const am_volume_t volume, const am_CustomRampType_t ramp, const am_time_t time);
+    am_Error_e asyncSetSourceState(const am_Handle_s handle, const am_sourceID_t sourceID, const am_SourceState_e state);
+    am_Error_e asyncSetSinkSoundProperties(const am_Handle_s handle, const am_sinkID_t sinkID, const std::vector<am_SoundProperty_s>& listSoundProperties);
+    am_Error_e asyncSetSinkSoundProperty(const am_Handle_s handle, const am_sinkID_t sinkID, const am_SoundProperty_s& soundProperty);
+    am_Error_e asyncSetSourceSoundProperties(const am_Handle_s handle, const am_sourceID_t sourceID, const std::vector<am_SoundProperty_s>& listSoundProperties);
+    am_Error_e asyncSetSourceSoundProperty(const am_Handle_s handle, const am_sourceID_t sourceID, const am_SoundProperty_s& soundProperty);
+    am_Error_e asyncCrossFade(const am_Handle_s handle, const am_crossfaderID_t crossfaderID, const am_HotSink_e hotSink, const am_CustomRampType_t rampType, const am_time_t time);
+    am_Error_e setDomainState(const am_domainID_t domainID, const am_DomainState_e domainState);
+    am_Error_e returnBusName(std::string& BusName) const;
+    void getInterfaceVersion(std::string& out_ver) const;
+
+    void setPAContext(pa_context *p_paContext) {
+        this->m_paContext = p_paContext;
+    }
+    am_Error_e asyncSetVolumes(const am_Handle_s handle, const std::vector<am_Volumes_s>& listVolumes);
+    am_Error_e asyncSetSinkNotificationConfiguration(const am_Handle_s handle, const am_sinkID_t sinkID, const am_NotificationConfiguration_s& notificationConfiguration);
+    am_Error_e asyncSetSourceNotificationConfiguration(const am_Handle_s handle, const am_sourceID_t sourceID, const am_NotificationConfiguration_s& notificationConfiguration);
+//Pulse Audio callbacks
+    void getSinkInfoCallback(pa_context *c, const pa_sink_info *i, int is_last, void *userdata);
+    void getSourceInfoCallback(pa_context *c, const pa_source_info *i, int is_last, void *userdata);
+    void getSinkInputInfoCallback(pa_context *c, const pa_sink_input_info *i, void *userdata);
+    void getSourceOutputInfoCallback(pa_context *c, const pa_source_output_info *i, void *userdata);
+
+private:
+    void loadConfig();
+
+    am_Domain_s                                     m_domain;
+
+    std::vector<RoutingSenderPULSESourceSinkConfig> m_sinks;
+    std::vector<RoutingSenderPULSESourceSinkConfig> m_sources;
+
+    std::map<uint16_t, uint32_t>                    m_sourceToPASinkInput;
+    std::map<uint16_t, uint32_t>                    m_sourceToPASource;
+    std::map<uint16_t, uint32_t>                    m_sinkToPASourceOutput;
+    std::map<uint16_t, uint32_t>                    m_sinkToPASink;
+
+    uint16_t                                        m_paSinkNullIndex;
+    uint16_t                                        m_paSourceNullIndex;
+
+    IAmRoutingReceive                               *m_routingReceiver;
+    pa_context                                      *m_paContext;
+
+/**
+ * Maintain a list of pending actions: there is a high change that the HMI first call connect,
+ * then the audio client start to play, therefore, sink-input is not yet created by the time "connect" method was called.
+ * same for volume? not sure - probably the sink input is created when the user change the volume.
+ * same for disconnect? not sure - probably the sink input was already created by the time the user is calling disconnect
+ */
+    std::vector<RoutingSenderPULSEConnection>       m_activeConnections;
+    std::map<uint16_t, uint16_t>                    m_sinkToVolume;
+    std::map<uint16_t, uint16_t>                    m_sourceToVolume;
+};
+
+#endif
diff --git a/PluginRoutingInterfacePulse/src/RoutingSenderMainloopPULSE.cpp b/PluginRoutingInterfacePulse/src/RoutingSenderMainloopPULSE.cpp
new file mode 100644
index 0000000..0def61f
--- /dev/null
+++ b/PluginRoutingInterfacePulse/src/RoutingSenderMainloopPULSE.cpp
@@ -0,0 +1,610 @@
+/**
+ * SPDX license identifier: MPL-2.0
+ *
+ * Copyright (C) 2011-2014, Wind River Systems
+ * Copyright (C) 2014, GENIVI Alliance
+ *
+ * This file is part of Pulse Audio Interface Routing Plugin.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License (MPL), v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * For further information see http://www.genivi.org/.
+ *
+ * List of changes:
+ *
+ * 21.08.2014, Adrian Scarlat, First version of the code;
+ *                             Porting code from AM ver1.x to AM ver3.0;
+ *                             Added Copyright and License information;
+ */
+
+/* Includes */
+
+#include <pthread.h>
+#include "shared/CAmDltWrapper.h"
+#include "RoutingSenderPULSE.h"
+#include "RoutingSenderMainloopPULSE.h"
+
+static pthread_t        *p_thread;
+static pa_mainloop      *main_loop;
+
+/* struct used for ramp_volume changing */
+typedef struct ramp_volume
+{
+    uint32_t sink_input_index;
+    uint32_t volume_ini;
+    uint32_t volume_end;
+    /* max ramp time in ms */
+    uint16_t ramp_max_time;
+    /* current delay between calls in ms */
+    uint16_t ramp_crt_elapsed;
+    /* aux used to calculate delay between calls */
+    timespec start_time;
+};
+/* map used for storing ramp_volume information for sources */
+std::map<uint32_t, ramp_volume> g_sinkInputId2rampVolume;
+
+/* Defines */
+#define QUIT_REASON_PA_DOWN     1
+#define QUIT_REASON_AMGR_DOWN   2
+
+DLT_IMPORT_CONTEXT(routingPulse)
+
+bool routing_sender_create_mainloop(void *thiz)
+{
+    if (!thiz) {
+        logError("Can not create an working thread for Pulse Audio without a Routing plugin\n");
+        return false;
+    }
+    p_thread = (pthread_t *) malloc(sizeof(pthread_t));
+    pthread_create(p_thread, NULL, routing_sender_start_mainloop, thiz);
+    return true;
+}
+
+
+void* routing_sender_start_mainloop(void *thiz)
+{
+    pa_mainloop_api  *mainloop_api;
+    pa_proplist      *proplist;
+    pa_context       *context;
+    int              ret = 0;
+
+    if (!thiz) {
+        logError("Can not create an working thread for Pulse Audio without a Routing plugin\n");
+        return NULL;
+    }
+
+    proplist = pa_proplist_new();
+    if (pa_proplist_sets(proplist, PA_PROP_APPLICATION_NAME, "RoutingPULSE") < 0) {
+        logError("Can not prepare Pulse Audio main loop: pa_proplist_sets\n");
+        goto end;
+    }
+
+    if (!(main_loop = pa_mainloop_new()))
+    {
+        logError("Can not prepare Pulse Audio main loop: pa_mainloop_new\n");
+        goto end;
+    }
+
+    if (!(mainloop_api = pa_mainloop_get_api(main_loop)))
+    {
+        logError("Can not prepare Pulse Audio main loop: pa_mainloop_get_api\n");
+        goto end;
+    }
+
+    if (!(context = pa_context_new_with_proplist(mainloop_api, NULL, proplist)))
+    {
+        logError("Can not prepare Pulse Audio main loop: pa_context_new_with_proplist\n");
+        goto end;
+    }
+
+    pa_context_set_state_callback(context, routing_sender_context_state_callback, thiz);
+
+    if (pa_context_connect(context, NULL, pa_context_flags_t(0), NULL) < 0)
+    {
+        logError("Can not prepare Pulse Audio main loop: pa_context_new_with_proplist\n");
+        goto end;
+    }
+    ((RoutingSenderPULSE *) thiz)->setPAContext(context);
+
+    pa_mainloop_run(main_loop, &ret);
+
+end:
+    if (ret == QUIT_REASON_PA_DOWN)
+    {
+        ret = 0;
+        //mail loop ended
+        if (context)
+        {
+            pa_context_disconnect(context);
+            pa_context_unref(context);
+            context = NULL;
+        }
+
+        if (proplist)
+        {
+            pa_proplist_free(proplist);
+            proplist = NULL;
+        }
+
+        if (main_loop)
+        {
+            //pa_signal_done();
+            pa_signal_done();
+            pa_mainloop_free(main_loop);
+            main_loop = NULL;
+        }
+
+        //... pulse audio is down ... retry to connect
+        usleep(100000);
+        routing_sender_start_mainloop(thiz);
+    }
+    //TDOO: else if -check other value for "ret"
+    else
+    {
+        return thiz;
+    }
+}
+
+
+void routing_sender_pa_event_callback(pa_context *c, pa_subscription_event_type_t t, uint32_t idx, void *thiz)
+{
+    switch(t)
+    {
+        case PA_SUBSCRIPTION_EVENT_SINK_INPUT:
+        {
+            pa_context_get_sink_input_info(
+                    c, idx, routing_sender_get_sink_input_info_callback, thiz);
+            break;
+        }
+        case PA_SUBSCRIPTION_EVENT_SOURCE_OUTPUT:
+        {
+            pa_context_get_sink_input_info(
+                    c, idx, routing_sender_get_sink_input_info_callback, thiz);
+            break;
+        }
+        default:
+        {
+            logInfo("Pulse Audio event", t, "was ignored");
+        }
+    }
+}
+
+
+void routing_sender_get_sink_input_info_callback(pa_context *c, const pa_sink_input_info *i, int eol, void *userdata)
+{
+    (void) eol;
+
+    RoutingSenderPULSE* thiz = (RoutingSenderPULSE*) userdata;
+    if (!thiz)
+    {
+        logError("pa_context_get_sink_input_info was called with wrong params\n");
+        return;
+    }
+
+    /* init map of ramp_volumes, usefull later */
+    if (i != NULL && strcmp(i->name,"null") != 0)
+    {
+        ramp_volume source_ramp_volume;
+        source_ramp_volume.sink_input_index = i->index;
+        source_ramp_volume.ramp_crt_elapsed = 0;
+        g_sinkInputId2rampVolume.insert(std::make_pair(i->index, source_ramp_volume));
+    }
+
+    thiz->getSinkInputInfoCallback(c, i, userdata);
+}
+
+
+void routing_sender_get_source_output_info_callback(pa_context *c, const pa_source_output_info *i, int eol, void *userdata)
+{
+    (void) eol;
+
+    RoutingSenderPULSE* thiz = (RoutingSenderPULSE*) userdata;
+    if (!thiz)
+    {
+        logError("pa_context_get_surce_output_info was called with wrong params\n");
+        return;
+    }
+    thiz->getSourceOutputInfoCallback(c, i, userdata);
+}
+
+
+
+void routing_sender_get_sink_info_callback(pa_context *c, const pa_sink_info *i, int is_last, void *userdata)
+{
+    RoutingSenderPULSE* thiz = (RoutingSenderPULSE*) userdata;
+    if (!thiz)
+    {
+        logError("pa_context_get_sink_info was called with wrong params\n");
+        return;
+    }
+    thiz->getSinkInfoCallback(c, i, is_last, userdata);
+}
+
+
+void routing_sender_get_source_info_callback(pa_context *c, const pa_source_info *i, int is_last, void *userdata)
+{
+    RoutingSenderPULSE* thiz = (RoutingSenderPULSE*) userdata;
+    if (!thiz)
+    {
+        logError("pa_context_get_source_info was called with wrong params\n");
+        return;
+    }
+    thiz->getSourceInfoCallback(c, i, is_last, userdata);
+}
+
+
+void routing_sender_subscriber_callback(pa_context *c, int success, void *thiz) {
+    if (success)
+    {
+        pa_operation *o = pa_context_get_sink_info_list(c, routing_sender_get_sink_info_callback, thiz);
+        if (o)
+        {
+            pa_operation_unref(o);
+        }
+        else
+        {
+            logError("Unable to create Pulse Audio operation:",
+                    "pa_context_get_sink_info_list");
+        }
+    }
+    else
+    {
+        logError("routing_sender_subscriber_callback: success = false");
+    }
+}
+
+
+void routing_sender_context_state_callback(pa_context *c, void *thiz)
+ {
+
+    if (pa_context_get_state(c) == PA_CONTEXT_FAILED)
+    {
+        pa_mainloop_quit(main_loop, QUIT_REASON_PA_DOWN);
+    }
+    if (pa_context_get_state(c) == PA_CONTEXT_READY)
+    {
+        //when context is ready - subscriber for server events (we are mainly interested in sink inputs & source outputs)
+        pa_context_set_subscribe_callback(c, routing_sender_pa_event_callback, thiz);
+        pa_operation *o = pa_context_subscribe(c, PA_SUBSCRIPTION_MASK_ALL, routing_sender_subscriber_callback, thiz);
+        if (o)
+        {
+            pa_operation_unref(o);
+        }
+        else
+        {
+            logError("Unable to create Pulse Audio operation:",
+                            "pa_context_subscribe");
+        }
+    }
+    //other states are not relevant
+}
+
+
+bool routing_sender_get_source_info(pa_context *c, void *thiz) {
+    if (pa_context_get_state(c) == PA_CONTEXT_READY)
+    {
+        pa_operation *o = pa_context_get_source_info_list(c, routing_sender_get_source_info_callback, thiz);
+        if (o)
+        {
+            pa_operation_unref(o);
+        }
+        else
+        {
+            logError("Unable to create Pulse Audio operation:",
+                    "pa_context_get_sink_info_list");
+            return false;
+        }
+    }
+    else
+    {
+        logError("Can not get Pulse Audio sources info - context not ready\n");
+        return false;
+    }
+
+    return true;
+}
+
+
+bool routing_sender_move_sink_input(pa_context *c, uint32_t sink_input_index, uint32_t sink_index, void *thiz)
+{
+    if (pa_context_get_state(c) == PA_CONTEXT_READY)
+    {
+        pa_operation *o = pa_context_move_sink_input_by_index(c, sink_input_index, sink_index, NULL, thiz);
+        if (o)
+        {
+            pa_operation_unref(o);
+        }
+        else
+        {
+            logError("Unable to create Pulse Audio operation:",
+                    "pa_context_move_sink_input_by_index");
+            return false;
+        }
+    }
+    else
+    {
+        logError("Can not move sink input - context not ready\n");
+        return false;
+    }
+    return true;
+}
+
+
+bool routing_sender_move_source_output(pa_context *c, uint32_t source_output_index, uint32_t source_index, void *thiz)
+{
+    if (pa_context_get_state(c) == PA_CONTEXT_READY)
+    {
+        pa_operation *o = pa_context_move_source_output_by_index(c, source_output_index, source_index, NULL, thiz);
+        if (o)
+        {
+            pa_operation_unref(o);
+        }
+        else
+        {
+            logError("Unable to create Pulse Audio operation:",
+                    "pa_context_set_sink_input_volume");
+            return false;
+        }        
+    }
+    else
+    {
+        logError("Can not move source output - context not ready\n");
+        return false;
+    }
+    return true;
+}
+
+static inline uint16_t timespec2mili(const timespec & time)
+{
+    return (uint16_t)((time.tv_nsec == -1 && time.tv_sec == -1) ?
+                      -1 :
+                      time.tv_sec * 1000 + time.tv_nsec / 1000000);
+}
+
+/* Considers that time2 > time1 */
+static inline uint16_t timespec2DeltaMili(const timespec & time1, const timespec & time2)
+{
+    timespec l_deltaTime;
+    l_deltaTime.tv_sec = time2.tv_sec - time1.tv_sec;
+    l_deltaTime.tv_nsec = time2.tv_nsec - time1.tv_nsec;
+    return timespec2mili(l_deltaTime);
+}
+
+static void routing_sender_sink_input_volume_cb(pa_context *c, int success, void *data)
+{
+    logInfo("routing_sender_sink_input_volume_cb: success=", success, " data=", data);
+    if (success)
+    {
+        ramp_volume * l_ramp_volume = (ramp_volume *)data;
+        timespec l_endTime;
+        clock_gettime(0, &l_endTime);
+        l_ramp_volume->ramp_crt_elapsed = timespec2DeltaMili(l_ramp_volume->start_time, l_endTime);
+        if (l_ramp_volume->ramp_crt_elapsed >= l_ramp_volume->ramp_max_time)
+        {
+            return;
+        }
+
+        logInfo("routing_sender_sink_input_volume_cb: ms elapsed=", l_ramp_volume->ramp_crt_elapsed, " of ", l_ramp_volume->ramp_max_time);
+
+        /* ######## Calculate new volume with formula: ##########
+                                crt_time x ( vol_end - vol_ini )
+           new_vol = vol_ini + ----------------------------------
+                                            max_time
+           ###################################################### */
+        uint32_t new_volume =
+                l_ramp_volume->volume_ini +
+                ( ( l_ramp_volume->ramp_crt_elapsed * ( l_ramp_volume->volume_end - l_ramp_volume->volume_ini ) ) / l_ramp_volume->ramp_max_time );
+        logInfo("routing_sender_sink_input_volume_cb: vol_ini=",l_ramp_volume->volume_ini,"vol_crt=",new_volume,"vol_end=",l_ramp_volume->volume_end);
+
+
+        /* ***** Set volume again ***** */
+        pa_cvolume *volumeCh = (pa_cvolume *) malloc(sizeof(pa_cvolume));
+        volumeCh->channels = 1;//TODO: check is stream is mono / stereo
+        volumeCh->values[0] = new_volume;
+
+        pa_operation *o = pa_context_set_sink_input_volume(c, l_ramp_volume->sink_input_index, volumeCh, NULL, NULL);
+        if (o)
+        {
+            pa_operation_unref(o);
+        }
+        else
+        {
+            logError("Unable to create Pulse Audio operation:",
+                    "pa_context_set_sink_input_volume");
+            return ;
+        }
+        usleep(10000);
+
+        volumeCh->channels = 2;//TODO: check is stream is mono / stereo
+        volumeCh->values[0] = new_volume;
+        volumeCh->values[1] = new_volume;
+        logInfo("routing_sender_sink_input_volume_cb: will set vol=", new_volume);
+        o = pa_context_set_sink_input_volume(c, l_ramp_volume->sink_input_index, volumeCh, routing_sender_sink_input_volume_cb, l_ramp_volume);
+        if (o)
+        {
+            pa_operation_unref(o);
+        }
+        else
+        {
+            logError("Unable to create Pulse Audio operation:",
+                    "pa_context_set_sink_input_volume");
+            return ;
+        }
+    }
+
+}
+
+bool routing_sender_sink_input_volume_ramp(pa_context *c, uint32_t sink_input_index, uint32_t crt_volume, uint32_t volume, uint16_t ramp_time, void *thiz)
+{
+    if (pa_context_get_state(c) == PA_CONTEXT_READY)
+    {
+        /* before everything, check to see if ramp_volume struct exists */
+        std::map<uint32_t, ramp_volume>::iterator iter = g_sinkInputId2rampVolume.find(sink_input_index);
+        std::map<uint32_t, ramp_volume>::iterator iterEnd = g_sinkInputId2rampVolume.end();
+        if (iter != iterEnd)
+        {
+            /* set test volume with only 1 unit more or less, just to see how callback responds */
+            pa_volume_t test_volume = ((crt_volume * MAX_PULSE_VOLUME) / 100);
+            test_volume += volume > crt_volume ? 1 : -1;
+
+            pa_cvolume *volumeCh = (pa_cvolume *) malloc(sizeof(pa_cvolume));
+            volumeCh->channels = 1;//TODO: check is stream is mono / stereo
+            volumeCh->values[0] = test_volume;
+
+            pa_operation *o = pa_context_set_sink_input_volume(c, sink_input_index, volumeCh, NULL, NULL);
+            if (o)
+            {
+                pa_operation_unref(o);
+            }
+            else
+            {
+                logError("Unable to create Pulse Audio operation:",
+                        "pa_context_set_sink_input_volume");
+                return false;
+            }
+
+            volumeCh->channels = 2;//TODO: check is stream is mono / stereo
+            volumeCh->values[0] = test_volume;
+            volumeCh->values[1] = test_volume;
+
+            ramp_volume * l_ramp_volume = (ramp_volume *) &iter->second;
+            logInfo("routing_sender_sink_input_volume_ramp: searching ",sink_input_index,"found ramp_vlume struct with sinkInputId ",l_ramp_volume->sink_input_index," (should be equal) ");
+            l_ramp_volume->volume_ini = (crt_volume * MAX_PULSE_VOLUME) / 100;
+            l_ramp_volume->volume_end = (volume * MAX_PULSE_VOLUME) / 100;
+            l_ramp_volume->ramp_max_time = ramp_time;
+            clock_gettime(0, &l_ramp_volume->start_time);
+            l_ramp_volume->ramp_crt_elapsed = 0;
+            logInfo("routing_sender_sink_input_volume_ramp: will set vol=", test_volume);
+            o = pa_context_set_sink_input_volume(c, sink_input_index, volumeCh, routing_sender_sink_input_volume_cb, l_ramp_volume);
+            if (o)
+            {
+                pa_operation_unref(o);
+            }
+            else
+            {
+                logError("Unable to create Pulse Audio operation:",
+                        "pa_context_set_sink_input_volume");
+                return false;
+            }
+        }
+        else
+        {
+            logInfo("routing_sender_sink_input_volume_ramp: didn't find struct with sinkInputId ", sink_input_index);
+            /* make-it the old traditional way */
+            return routing_sender_sink_input_volume(c, sink_input_index, volume, thiz);
+        }
+
+
+    }
+    else
+    {
+        logError("Can not set sink input volume - context not ready\n");
+        return false;
+    }
+    return true;
+}
+
+bool routing_sender_sink_input_volume(pa_context *c, uint32_t sink_input_index, uint32_t volume, void *thiz)
+{
+    if (pa_context_get_state(c) == PA_CONTEXT_READY)
+    {
+        pa_cvolume *volumeCh = (pa_cvolume *) malloc(sizeof(pa_cvolume));
+        volumeCh->channels = 1;//TODO: check is stream is mono / stereo
+        volumeCh->values[0] = (volume * MAX_PULSE_VOLUME) / 100;
+
+        pa_operation *o = pa_context_set_sink_input_volume(c, sink_input_index, volumeCh, NULL, thiz);
+        if (o)
+        {
+            pa_operation_unref(o);
+        }
+        else
+        {
+            logError("Unable to create Pulse Audio operation:",
+                    "pa_context_set_sink_input_volume");
+            return false;
+        }
+
+        volumeCh->channels = 2;//TODO: check is stream is mono / stereo
+        volumeCh->values[0] = (volume * MAX_PULSE_VOLUME) / 100;
+        volumeCh->values[1] = (volume * MAX_PULSE_VOLUME) / 100;
+
+        o = pa_context_set_sink_input_volume(c, sink_input_index, volumeCh, NULL, NULL);
+        if (o)
+        {
+            pa_operation_unref(o);
+        }
+        else
+        {
+            logError("Unable to create Pulse Audio operation:",
+                    "pa_context_set_sink_input_volume");
+            return false;
+        }
+    }
+    else
+    {
+        logError("Can not set sink input volume - context not ready\n");
+        return false;
+    }
+    return true;
+}
+
+
+bool routing_sender_sink_input_mute(pa_context *c, uint32_t sink_input_index, bool mute, void *thiz)
+{
+    if (pa_context_get_state(c) == PA_CONTEXT_READY)
+    {
+        pa_operation *o = pa_context_set_sink_input_mute(
+            c, sink_input_index, mute ? 1 : 0, NULL, thiz);
+        if (o)
+        {
+            pa_operation_unref(o);
+        }
+        else
+        {
+            logError("Unable to create Pulse Audio operation:",
+                    "pa_context_set_sink_input_mute");
+            return false;
+        }
+    }
+    else
+    {
+        logError("Can not set sink input volume - context not ready\n");
+        return false;
+    }
+    return true;
+}
+
+
+bool routing_sender_sink_volume(pa_context *c, uint32_t sink_index, uint32_t volume, void *thiz)
+{
+    if (pa_context_get_state(c) == PA_CONTEXT_READY)
+    {
+        pa_cvolume *volumeCh = (pa_cvolume *) malloc(sizeof(pa_cvolume));
+        volumeCh->channels = 2;//TODO: check is stream is mono / stereo
+        volumeCh->values[0] = (volume * MAX_PULSE_VOLUME) / 100;
+        volumeCh->values[1] = (volume * MAX_PULSE_VOLUME) / 100;
+
+        pa_operation *o = pa_context_set_sink_volume_by_index(c, sink_index, volumeCh, NULL, thiz);
+        if (o)
+        {
+            pa_operation_unref(o);
+        }
+        else
+        {
+            logError("Unable to create Pulse Audio operation:",
+                    "pa_context_set_sink_input_volume");
+            return false;
+        }
+    }
+    else
+    {
+        logError("Can not set sink input volume - context not ready\n");
+        return false;
+    }
+    return true;
+}
+
+//TODO - implements mute/un-mute and sink suspend(pause)
+//TODO - IMPORTANT !! implement volume change for sink input even multiple sink inputs are created during one connection
diff --git a/PluginRoutingInterfacePulse/src/RoutingSenderPULSE.cpp b/PluginRoutingInterfacePulse/src/RoutingSenderPULSE.cpp
new file mode 100644
index 0000000..05259b0
--- /dev/null
+++ b/PluginRoutingInterfacePulse/src/RoutingSenderPULSE.cpp
@@ -0,0 +1,923 @@
+/**
+ * SPDX license identifier: MPL-2.0
+ *
+ * Copyright (C) 2011-2014, Wind River Systems
+ * Copyright (C) 2014, GENIVI Alliance
+ *
+ * This file is part of Pulse Audio Interface Routing Plugin.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License (MPL), v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * For further information see http://www.genivi.org/.
+ *
+ * List of changes:
+ *
+ * 21.08.2014, Adrian Scarlat, First version of the code; 
+ *                             Porting code from AM ver1.x to AM ver3.0;
+ *                             Added Copyright and License information;
+ *
+ * 
+ * DESCRIPTION
+ *
+ * This module is handling requests form AudioManager daemon and redirect them to Pulse Audio server.
+ * It keeps track of existing audio sink, sources, sink-input, sources-input and performs connection/disconnection
+ * and other operations upon AudioManager daemon request.
+ *
+ * The modul is configured with a static list of sink and sources.
+ *   Sinks are: audio output(e.g. speakers) or recording applications.
+ *   Sources are: playback applications or audio input(e.g. microphone)
+ *
+ * In PulseAudio server those are classified as follows:
+ *  - audio output             - sinks:   identified by name or properties: device.api (e.g = "alsa") & device.class(e.g. = "sound")
+ *  - audio input              - sources: identified by name or properties: device.api (e.g = "alsa") & device.class(e.g. = "sound")
+ *  - playback applications    - sink inputs: identified by application.name (e.g. "ALSA plug-in [chromium-browser]",
+ *  - recording applications   - source outputs: identified by application.name (e.g. "ALSA plug-in [chromium-browser]",
+ *    application.process.user = "popai", application.process.binary = "chromium-browser")
+ *
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <iostream>
+
+#include "shared/CAmDltWrapper.h"
+
+#include "RoutingSenderPULSE.h"
+#include "RoutingSenderMainloopPULSE.h"
+
+
+
+#define LIBNAME "libPluginRoutingInterfacePULSE.so"
+#define CFGNAME "libPluginRoutingInterfacePULSE.conf"
+
+/* Globals */
+
+
+/* Defines */
+DLT_DECLARE_CONTEXT(routingPulse)
+/* Maximum source volume measured in percentage. Minimum value is 0% */
+#define MAX_SOURCE_VOLUME   (100)
+
+
+/**
+ * Factory function for the plug-in to be used by audio manager daemon with dlopen & dlsym functions.
+ * Pattern "libraryName"FACTORY
+ *
+ * @author  Ionut Popa (ionut.popa@windriver.com)
+ * @return  an instance of RoutingSendInterface or type RoutingSenderPULSE.
+ */
+extern "C" IAmRoutingSend* PluginRoutingInterfacePULSEFactory()
+{
+
+    return (new RoutingSenderPULSE(NULL));
+}
+
+/**
+ * Destructor function for the plug-in to be used by audio manager daemon with dl_open & dl_sym functions.
+ *
+ * @param  routingSendInterface - the instance created by PluginRoutingInterfaceDbusFactory
+ * @author Ionut Popa (ionut.popa@windriver.com)
+ */
+extern "C" void destroyPluginRoutingInterfacePULSE(IAmRoutingSend* routingSendInterface)
+{
+    delete routingSendInterface;//virtual destructor -> our constructor will be called too
+}
+
+
+/**
+ * Constructor.
+ * @param p_paContext - reference to PulseAudio context
+ */
+RoutingSenderPULSE::RoutingSenderPULSE(pa_context *p_paContext)
+{
+    this->m_paSinkNullIndex = -1;
+    this->m_paSourceNullIndex = -1;
+    this->m_paContext = p_paContext;
+    this->loadConfig();
+}
+
+
+void RoutingSenderPULSE::loadConfig()
+{
+    //get current library path - search: /proc/< getpid() >/maps
+    char proc_maps_file_name[256];
+    char line[256];
+    char lib_name[256];
+    char *tmp;
+    pid_t pid = getpid();
+    snprintf(proc_maps_file_name, 256,  "/proc/%d/maps", pid);
+    FILE *proc_maps = fopen(proc_maps_file_name, "r");
+
+    while (!feof(proc_maps))
+    {
+        char *cnt = fgets(line, 256, proc_maps);
+        if (strlen(line) == 0 || line[0] == '#')
+        {
+            continue;
+        }
+        if (cnt == NULL) continue;
+        //tmp0 tmp1 tmp2 tmp3 tmp4 lib_name);
+        tmp = strtok(line, " ");//address-interval
+        if(tmp == NULL) continue;
+
+        tmp = strtok(NULL, " ");//rights
+        if(tmp == NULL) continue;
+
+        tmp = strtok(NULL, " ");//offset
+        if(tmp == NULL) continue;
+
+        strtok(NULL, " ");//dev
+        if(tmp == NULL) continue;
+
+        tmp = strtok(NULL, " \n");//inode
+        if(tmp == NULL) continue;
+
+        tmp = strtok(NULL, " \n");
+        if(tmp == NULL) continue;
+
+        strcpy(lib_name, tmp);
+        if ((lib_name != NULL) && (strstr(lib_name, LIBNAME) >= lib_name))
+        {
+            strcpy(strrchr(lib_name, '/') + 1, CFGNAME);
+            logInfo("PULSE - config file name: %s\n", lib_name);
+
+            FILE *config = fopen(lib_name, "r");
+
+            while (config && !feof(config))
+            {
+                char *cnt = fgets(line, 256, config);
+                if (!line || strlen(line) == 0) continue;
+                //config format line: TYPE|PULSE TYPE|NAME|CLASS|PROPERTY_NAME|PROPERTY_VALUE
+                //TYPE="Source" or "Sink"
+
+                char *tmp = strtok(line, "|");//type
+                if (strcmp("Sink", tmp) == 0)
+                {
+                    //add sink config
+                    RoutingSenderPULSESourceSinkConfig sinkConfig;
+
+                    tmp = strtok(NULL, "|");//pulse type - not used for the moment
+
+                    tmp = strtok(NULL, "|");//class
+                    sinkConfig.clazz = std::string(tmp);
+
+                    tmp = strtok(NULL, "|");//name
+                    sinkConfig.name = std::string(tmp);
+
+                    tmp = strtok(NULL, "|");//property name
+                    sinkConfig.propertyName = std::string(tmp);
+
+                    tmp = strtok(NULL, "|\n");//property value
+                    sinkConfig.propertyValue = std::string(tmp);
+
+                    m_sinks.push_back(sinkConfig);
+                    logInfo("sinkConfig: sinkConfig.clazz=", sinkConfig.clazz, " sinkConfig.name=", sinkConfig.name, " sinkConfig.propertyName=", sinkConfig.propertyName, " sinkConfig.propertyValue=", sinkConfig.propertyValue);
+                }
+                if (strcmp("Source", tmp) == 0)
+                {
+                    //add source config
+                    RoutingSenderPULSESourceSinkConfig sourceConfig;
+
+                    tmp = strtok(NULL, "|");//pulse type - not used for the moment
+
+                    tmp = strtok(NULL, "|");//class
+                    sourceConfig.clazz = std::string(tmp);
+
+                    tmp = strtok(NULL, "|");//name
+                    sourceConfig.name = std::string(tmp);
+
+                    tmp = strtok(NULL, "|");//property name
+                    sourceConfig.propertyName = std::string(tmp);
+
+                    tmp = strtok(NULL, "|\n");//property value
+                    sourceConfig.propertyValue = std::string(tmp);
+
+                    m_sources.push_back(sourceConfig);
+                    logInfo("sourceConfig: sourceConfig.clazz=", sourceConfig.clazz, " sourceConfig.name=", sourceConfig.name, " sourceConfig.propertyName=", sourceConfig.propertyName, " sourceConfig.propertyValue=", sourceConfig.propertyValue);
+                }
+            }
+
+            if (config)
+                fclose(config);
+            break;
+        }
+    }
+
+    fclose(proc_maps);
+}
+
+
+/**
+ * Destructor.
+ */
+RoutingSenderPULSE::~RoutingSenderPULSE()
+{
+    //TODO: Disconnect from pulse: quit main loop and free the context and stuff
+}
+
+/**
+ * Connecting sender & receiver
+ * @author Ionut Popa (ionut.popa@windriver.com)
+ */
+am_Error_e RoutingSenderPULSE::startupInterface(am::IAmRoutingReceive *p_routingReceiver)
+{
+    this->m_routingReceiver = p_routingReceiver;
+    return am::E_OK;
+}
+
+void RoutingSenderPULSE::setRoutingReady(uint16_t handle)
+{
+    //TODO: do not register sinks with the same name
+
+    int i;
+
+    //first register Domain = PulseAudio
+    this->m_domain.name     = "PulseAudio";
+    this->returnBusName(this->m_domain.busname);//set domain bus name = current interface bus name
+    this->m_domain.nodename = "PulseAudio";
+    this->m_domain.early    = false;
+    this->m_domain.complete = true;
+    this->m_domain.state    = am::DS_CONTROLLED;
+
+    this->m_domain.domainID = 0;
+    this->m_routingReceiver->registerDomain(this->m_domain, this->m_domain.domainID);
+
+    am_SoundProperty_s l_spTreble;
+    l_spTreble.type = SP_GENIVI_BASS;
+    l_spTreble.value = 0;
+
+    am_SoundProperty_s l_spMid;
+    l_spMid.type = SP_GENIVI_MID;
+    l_spMid.value = 0;
+
+    am_SoundProperty_s l_spBass;
+    l_spBass.type = SP_GENIVI_BASS;
+    l_spBass.value = 0;
+
+    //register sources (sink inputs & sinks)
+    for (i = 0; i < m_sources.size(); i++)
+    {
+        am_sourceID_t l_newSourceID = 0;
+        this->m_sources[i].source.sourceID = l_newSourceID;
+        this->m_sources[i].source.name = m_sources[i].name;
+        this->m_sources[i].source.sourceState = am::SS_ON;
+        this->m_sources[i].source.domainID = this->m_domain.domainID;
+        this->m_sources[i].source.visible = true;
+        this->m_sources[i].source.volume = MAX_SOURCE_VOLUME; /* initialize source volume to 100% */
+
+        this->m_sources[i].source.listConnectionFormats.push_back(am::CF_GENIVI_STEREO);
+        this->m_routingReceiver->peekSourceClassID(
+                this->m_sources[i].clazz,
+                this->m_sources[i].source.sourceClassID);
+
+        this->m_routingReceiver->registerSource(this->m_sources[i].source, l_newSourceID);
+
+        this->m_sources[i].source.sourceID = l_newSourceID;
+        m_sourceToPASinkInput[l_newSourceID] = -1;
+        m_sourceToPASource[l_newSourceID] = -1;
+
+        logInfo("PULSE - register source:"
+            ,m_sources[i].name
+            , "(", m_sources[i].propertyName , ", ", m_sources[i].propertyValue, ")");
+        m_sourceToVolume[l_newSourceID] = MAX_SOURCE_VOLUME;//initially all the sources are at 100%
+    }
+
+    //register sinks (source outputs & sources)
+    for (i = 0; i < m_sinks.size(); i++)
+    {
+        am_sinkID_t l_newsinkID = 0;
+        this->m_sinks[i].sink.sinkID = l_newsinkID;
+        this->m_sinks[i].sink.name = this->m_sinks[i].name;
+        this->m_sinks[i].sink.muteState = am::MS_MUTED;
+        this->m_sinks[i].sink.domainID = this->m_domain.domainID;
+        this->m_sinks[i].sink.visible = true;
+
+        this->m_sinks[i].sink.listSoundProperties.push_back(l_spTreble);
+        this->m_sinks[i].sink.listSoundProperties.push_back(l_spMid);
+        this->m_sinks[i].sink.listSoundProperties.push_back(l_spBass);
+
+        this->m_sinks[i].sink.listConnectionFormats.push_back(am::CF_GENIVI_STEREO);
+
+        //printf("\nADS:Before: this->m_sinks[i].clazz = %s\n", this->m_sinks[i].clazz.c_str());
+        //printf("\nADS:Before: this->m_sinks[i].sink.sinkClassID = %d\n", this->m_sinks[i].sink.sinkClassID);
+        this->m_routingReceiver->peekSinkClassID(
+                this->m_sinks[i].clazz,
+                this->m_sinks[i].sink.sinkClassID);
+        //this->m_sinks[i].sink.sinkClassID = 1;
+        //printf("\nADS:After: this->m_sinks[i].clazz = %s\n", this->m_sinks[i].clazz.c_str());
+        //printf("\nADS:After: this->m_sinks[i].sink.sinkClassID = %d\n", this->m_sinks[i].sink.sinkClassID);
+
+        this->m_routingReceiver->registerSink(this->m_sinks[i].sink, l_newsinkID);
+        this->m_sinks[i].sink.sinkID = l_newsinkID;
+        m_sinkToPASourceOutput[l_newsinkID] = -1;
+        m_sinkToPASink[l_newsinkID] = -1;
+
+        logInfo("PULSE - register sink:"
+            ,m_sinks[i].name
+            , "(", m_sinks[i].propertyName , ", ", m_sinks[i].propertyValue, ")");
+    }
+
+    logInfo("PULSE - routingInterfacesReady");
+    this->m_routingReceiver->confirmRoutingReady(handle, am::E_OK);
+
+    //register pulse sink & sources, sink inputs & source outputs - > start the main PA loop
+    routing_sender_create_mainloop((void *) this);
+}
+
+void RoutingSenderPULSE::setRoutingRundown(uint16_t handle)
+{
+    this->m_routingReceiver->confirmRoutingRundown(handle, am::E_OK);
+    //TODO: implement this
+}
+
+am_Error_e RoutingSenderPULSE::asyncAbort(const am_Handle_s handle)
+{
+    (void) handle;
+    return E_NOT_USED;
+}
+
+
+am_Error_e RoutingSenderPULSE::asyncConnect(
+        const am_Handle_s handle,
+        const am_connectionID_t connectionID,
+        const am_sourceID_t sourceID,
+        const am_sinkID_t sinkID,
+        const am_CustomConnectionFormat_t connectionFormat)
+{
+    //TODO: check stuff like connectionFormat
+    //printf("ADS--> asyncConnect\n");
+    logInfo("PULSE - asyncConnect() - start");
+    //add source,sink & connectionID to a list of connections maintained by Routing Pulse Engine
+    RoutingSenderPULSEConnection l_newConnection;
+    l_newConnection.sinkID = sinkID;
+    l_newConnection.sourceID = sourceID;
+    l_newConnection.connectionID = connectionID;
+    l_newConnection.handle = handle;
+
+    //by default - sources ar connected at 100% -> controller is responsible to setSourcevolume if needed
+
+    m_sourceToVolume[sourceID] = MAX_SOURCE_VOLUME;
+
+
+    if (m_sinkToPASink[sinkID] != -1)
+    {
+        if (m_sourceToPASinkInput[sourceID] != -1)
+        {
+            if (routing_sender_move_sink_input(
+                    this->m_paContext,
+                    m_sourceToPASinkInput[sourceID],
+                    m_sinkToPASink[sinkID],
+                    this))
+            {
+                //TODO: add callback for pulse move sink input -> to send confirmation; for the moment directly send confirmation
+
+                logInfo("PULSE - asyncConnect() - connectionID:", connectionID,
+                        "move sinkInputIndex:", m_sourceToPASinkInput[sourceID], "to sinkIndex:", m_sinkToPASink[sinkID]);
+            }
+            else
+            {
+                this->m_routingReceiver->ackConnect(handle, connectionID, am::E_NOT_POSSIBLE);
+                return am::E_NOT_POSSIBLE;
+            }
+        }//else move_sink_input will be called later
+    }
+    else if (m_sourceToPASource[sourceID] != -1)
+    {
+        if (m_sinkToPASourceOutput[sinkID] != -1)
+        {
+            if (routing_sender_move_source_output(
+                    this->m_paContext,
+                    m_sinkToPASourceOutput[sinkID],
+                    m_sourceToPASource[sourceID],
+                    this))
+            {
+                //TODO: add callback for pulse move sink input -> to send confirmation; for the moment directly send confirmation
+
+                logInfo("PULSE - asyncConnect() - connectionID:", connectionID,
+                        "move sourceOutputIndex:", m_sinkToPASourceOutput[sinkID], "to sourceIndex:", m_sourceToPASource[sourceID]);
+
+            }
+            else
+            {
+                this->m_routingReceiver->ackConnect(handle, connectionID, am::E_NOT_POSSIBLE);
+                return am::E_NOT_POSSIBLE;
+            }
+        }//else move_sink_input will be called later
+    }
+    else
+    {
+        logError("Sink and source for connection not identified:",
+                sinkID, sourceID, connectionID);
+        return am::E_NOT_POSSIBLE;
+    }
+
+    m_activeConnections.push_back(l_newConnection);
+
+    this->m_routingReceiver->ackConnect(handle, connectionID, am::E_OK);
+
+/**
+ * TODO: connection is always possible ? check that
+*/
+
+    return am::E_OK;
+}
+
+
+am_Error_e RoutingSenderPULSE::asyncDisconnect(const am_Handle_s handle, const am_connectionID_t connectionID)
+{
+    //get connection by ID ... not to many connections, therefore linear search is fast enough
+    std::vector<RoutingSenderPULSEConnection>::iterator iter    = m_activeConnections.begin();
+    std::vector<RoutingSenderPULSEConnection>::iterator iterEnd = m_activeConnections.end();
+    for (; iter < iterEnd; ++iter)
+    {
+        if (iter->connectionID == connectionID)
+        {
+            if (m_sourceToPASinkInput[iter->sourceID] != -1)
+            {
+                if (this->m_paSinkNullIndex >= 0)
+                {
+                    //if null sink is defined - disconnect = move sink input to null
+                    logInfo("PULSE - asyncDisconnect() - connection found - move sinkInputIndex:",
+                            m_sourceToPASinkInput[iter->sourceID], "to NULL sinkIndex:", this->m_paSinkNullIndex);
+
+                    routing_sender_move_sink_input(
+                            this->m_paContext,
+                            this->m_sourceToPASinkInput[iter->sourceID],
+                            this->m_paSinkNullIndex,
+                            this);
+                    //TODO: add callback for pulse move sink input -> to send confirmation; for the moment directly send confirmation
+                    this->m_routingReceiver->ackDisconnect(handle, connectionID, am::E_OK);
+
+                }
+            }
+            else if (m_sinkToPASourceOutput[iter->sinkID] != -1)
+            {
+                if (this->m_paSourceNullIndex >= 0)
+                {
+                    //if null source is defined - disconnect = move source output to null
+                    logInfo("PULSE - asyncDisconnect() - connection found - move sourceOutputIndex:",
+                            m_sinkToPASourceOutput[iter->sinkID], "to NULL sourceIndex:", this->m_paSourceNullIndex);
+
+                    routing_sender_move_source_output(
+                            this->m_paContext,
+                            m_sourceToPASinkInput[iter->sourceID],
+                            this->m_paSinkNullIndex,
+                            this);
+                    //TODO: add callback for pulse move sink input -> to send confirmation; for the moment directly send confirmation
+                    this->m_routingReceiver->ackDisconnect(handle, connectionID, am::E_OK);
+
+                    //remove connection from the list of active connections
+                    iter = m_activeConnections.erase(iter);
+
+                    break;
+                }
+            }
+            else
+            {
+                logInfo("PULSE - asyncDisconnect() - connection found - but no sink input or source");
+                this->m_routingReceiver->ackDisconnect(handle, connectionID, am::E_OK);
+            }
+            //remove connection from the list of active connections
+            iter = m_activeConnections.erase(iter);
+
+            break;
+        }
+    }
+    return am::E_OK;
+}
+
+am_Error_e RoutingSenderPULSE::asyncSetSinkVolume(
+        const am_Handle_s handle,
+        const am_sinkID_t sinkID,
+        const am_volume_t volume,
+        const am_CustomRampType_t ramp,
+        const am_time_t time)
+{
+    (void) ramp;
+    (void) time;
+
+    logInfo("PULSE - asyncSetSinkVolume() - volume:", volume, "sink index:", this->m_sinkToPASink[sinkID]);
+
+    routing_sender_sink_volume(
+            this->m_paContext,
+            this->m_sinkToPASink[sinkID],
+            volume,
+            this);
+    this->m_routingReceiver->ackSetSinkVolumeChange(handle, volume, E_OK);
+    return E_OK;
+}
+
+am_Error_e RoutingSenderPULSE::asyncSetSourceVolume(
+        const am_Handle_s handle,
+        const am_sourceID_t sourceID,
+        const am_volume_t volume,
+        const am_CustomRampType_t ramp,
+        const am_time_t time)
+{
+    (void) ramp;
+    (void) time;
+
+    am_volume_t crt_volume = this->m_sourceToVolume[sourceID];
+    this->m_sourceToVolume[sourceID] = volume;
+
+    logInfo("PULSE - asyncSetSourceVolume() - volume:", volume, "sink input index:", this->m_sourceToPASinkInput[sourceID]);
+    if (m_sourceToPASinkInput[sourceID] != -1)
+    {
+        if (time == 0)
+        {/* without ramp time */
+            routing_sender_sink_input_volume(
+                    this->m_paContext,
+                    this->m_sourceToPASinkInput[sourceID],
+                    volume,
+                    this);
+        }
+        else
+        {/* with ramp time */
+            routing_sender_sink_input_volume_ramp(
+                    this->m_paContext,
+                    this->m_sourceToPASinkInput[sourceID],
+                    crt_volume,
+                    volume,
+                    (uint16_t)time,
+                    this);
+        }
+    }
+    else
+    {
+        logInfo("PULSE - sink input not registered yet - should wait for registration before update the volume");
+    }
+    this->m_routingReceiver->ackSetSourceVolumeChange(handle, volume, E_OK);
+
+}
+
+am_Error_e RoutingSenderPULSE::asyncSetSourceState(
+        const am_Handle_s handle,
+        const am_sourceID_t sourceID,
+        const am_SourceState_e state)
+{
+    logInfo("PULSE - asyncSetSourceState", state);
+    switch (state)
+    {
+        case SS_ON:
+        {
+            routing_sender_sink_input_mute(
+                    this->m_paContext,
+                    this->m_sourceToPASinkInput[sourceID],
+                    false,
+                    this
+            );
+            break;
+        }
+        case SS_OFF:
+        case SS_PAUSED:
+        {
+            //TODO: mute source in case of PAUSE or OFF - is there a better way to pause ? maybe suspending the associated sink?
+            routing_sender_sink_input_mute(
+                    this->m_paContext,
+                    this->m_sourceToPASinkInput[sourceID],
+                    true,
+                    this
+            );
+            break;
+        }
+        default:
+        {
+            logError("RoutingSenderPULSE::asyncSetSourceState - wrong source state\n");
+            this->m_routingReceiver->ackSetSourceState(handle, E_NOT_POSSIBLE);
+            return E_NOT_POSSIBLE;
+        }
+    }
+    this->m_routingReceiver->ackSetSourceState(handle, E_OK);
+    return E_OK;
+}
+
+am_Error_e RoutingSenderPULSE::asyncSetSinkSoundProperties(
+        const am_Handle_s handle,
+        const am_sinkID_t sinkID,
+        const std::vector<am_SoundProperty_s>& listSoundProperties)
+{
+    (void) handle;
+    (void) sinkID;
+    (void) listSoundProperties;
+    return E_NOT_USED;
+}
+
+am_Error_e RoutingSenderPULSE::asyncSetSinkSoundProperty(
+        const am_Handle_s handle,
+        const am_sinkID_t sinkID,
+        const am_SoundProperty_s& soundProperty)
+{
+    (void) handle;
+    (void) sinkID;
+    (void) soundProperty;
+    return E_NOT_USED;
+}
+
+am_Error_e RoutingSenderPULSE::asyncSetSourceSoundProperties(
+        const am_Handle_s handle,
+        const am_sourceID_t sourceID,
+        const std::vector<am_SoundProperty_s>& listSoundProperties)
+{
+    (void) handle;
+    (void) sourceID;
+    (void) listSoundProperties;
+    return E_NOT_USED;
+}
+
+am_Error_e RoutingSenderPULSE::asyncSetSourceSoundProperty(
+        const am_Handle_s handle,
+        const am_sourceID_t sourceID,
+        const am_SoundProperty_s& soundProperty)
+{
+    (void) handle;
+    (void) sourceID;
+    (void) soundProperty;
+    return E_NOT_USED;
+}
+
+am_Error_e RoutingSenderPULSE::asyncCrossFade(
+        const am_Handle_s handle,
+        const am_crossfaderID_t crossfaderID,
+        const am_HotSink_e hotSink,
+        const am_CustomRampType_t rampType,
+        const am_time_t time)
+{
+    (void) handle;
+    (void) crossfaderID;
+    (void) hotSink;
+    (void) rampType;
+    (void) time;
+    return E_NOT_USED;
+}
+
+am_Error_e RoutingSenderPULSE::setDomainState(
+        const am_domainID_t domainID,
+        const am_DomainState_e domainState)
+{
+    (void) domainID;
+    (void) domainState;
+    return E_NOT_USED;
+}
+
+am_Error_e RoutingSenderPULSE::returnBusName(std::string& BusName) const {
+    BusName = "RoutingPULSE";
+    return E_OK;
+}
+
+void RoutingSenderPULSE::getInterfaceVersion(std::string& out_ver) const
+{
+    out_ver = "3.0";
+}
+
+am_Error_e RoutingSenderPULSE::asyncSetVolumes(const am_Handle_s handle, const std::vector<am_Volumes_s>& listVolumes)
+{
+    (void) handle;
+    (void) listVolumes;
+    //todo: implement asyncSetVolumes;
+    return (E_NOT_USED);
+}
+
+am_Error_e RoutingSenderPULSE::asyncSetSinkNotificationConfiguration(const am_Handle_s handle, const am_sinkID_t sinkID, const am_NotificationConfiguration_s& notificationConfiguration)
+{
+    (void) handle;
+    (void) sinkID;
+    (void) notificationConfiguration;
+    //todo: implement asyncSetSinkNotificationConfiguration;
+    return (E_NOT_USED);
+}
+
+am_Error_e RoutingSenderPULSE::asyncSetSourceNotificationConfiguration(const am_Handle_s handle, const am_sourceID_t sourceID, const am_NotificationConfiguration_s& notificationConfiguration)
+{
+    (void) handle;
+    (void) sourceID;
+    (void) notificationConfiguration;
+    //todo: implement asyncSetSourceNotificationConfiguration;
+    return (E_NOT_USED);
+}
+/*******************************************************************************
+ * Private methods
+ ******************************************************************************/
+
+
+void RoutingSenderPULSE::getSinkInputInfoCallback(pa_context *c, const pa_sink_input_info *i, void *userdata)
+{
+    if (i == NULL)
+    {
+        return;
+    }
+
+    //search for corresponding Source
+    std::vector<RoutingSenderPULSESourceSinkConfig>::iterator iter    = m_sources.begin();
+    std::vector<RoutingSenderPULSESourceSinkConfig>::iterator iterEnd = m_sources.end();
+    for (; iter < iterEnd; ++iter)
+    {
+        //try to match source PulseAudio properties against config properties
+        const char *property_value = pa_proplist_gets(i->proplist, iter->propertyName.c_str());
+
+        if (property_value &&
+            ( std::string::npos != std::string(property_value).find(iter->propertyValue) ||
+              std::string::npos != iter->propertyValue.find(property_value)) )
+        {
+            logInfo("PULSE - sink input registered:"
+                , " sinkInputIndex:", i->index, "sourceID:", iter->source.sourceID);
+
+            logInfo("PULSE - sink input details:"
+                    , " prop_val: ", property_value, " iter->prop_val: ", iter->propertyValue);
+
+            m_sourceToPASinkInput[iter->source.sourceID] = i->index;
+
+            //iterate pending connection request
+            // -> if there is a connection pending such that sink input "i" matches source from Connect() - create the connection in pulse
+            std::vector<RoutingSenderPULSEConnection>::iterator iterConn    = m_activeConnections.begin();
+            std::vector<RoutingSenderPULSEConnection>::iterator iterConnEnd = m_activeConnections.end();
+            for (; iterConn < iterConnEnd; ++iterConn)
+            {
+                if (iterConn->sourceID == iter->source.sourceID)
+                {
+                    logInfo("PULSE - asyncConnect() - connectionID:", iterConn->connectionID,
+                            "move sinkInputIndex:", m_sourceToPASinkInput[iterConn->sourceID], "to sinkIndex:", m_sinkToPASink[iterConn->sinkID]);
+
+                    routing_sender_move_sink_input(
+                            this->m_paContext,
+                            m_sourceToPASinkInput[iterConn->sourceID],
+                            m_sinkToPASink[iterConn->sinkID],
+                            this);
+
+                    //TODO: add callback for pulse move sink input -> to send confirmation; for the moment directly send confirmation
+                    this->m_routingReceiver->ackConnect(iterConn->handle, iterConn->connectionID, am::E_OK);
+                }
+            }
+            //check of controller already requested vol adjustment  for this source
+            bool requiresVolUpdate = false;
+            for (int j = 0; j < i->volume.channels; j++)
+            {
+                if ((i->volume.values[j]*MAX_SOURCE_VOLUME / MAX_PULSE_VOLUME) != m_sourceToVolume[iter->source.sourceID])
+                {
+                    requiresVolUpdate = true;
+                    logInfo("PULSE - sink registerd with vol:", (i->volume.values[j]*MAX_SOURCE_VOLUME / MAX_PULSE_VOLUME),
+                            "; should be changed to:",
+                            m_sourceToVolume[iter->source.sourceID]);
+                    break;
+                }
+            }
+            if (requiresVolUpdate)
+            {
+                routing_sender_sink_input_volume(
+                        this->m_paContext,
+                        m_sourceToPASinkInput[iter->source.sourceID],
+                        m_sourceToVolume[iter->source.sourceID],
+                        this);
+            }
+            //TODO: check mute state was requested by controller.
+            break;
+        }
+    }
+}
+
+
+void RoutingSenderPULSE::getSourceOutputInfoCallback(pa_context *c, const pa_source_output_info *i, void *userdata)
+{
+    if (i == NULL)
+    {
+        return;
+    }
+
+    //search for corresponding Source
+    std::vector<RoutingSenderPULSESourceSinkConfig>::iterator iter    = m_sinks.begin();
+    std::vector<RoutingSenderPULSESourceSinkConfig>::iterator iterEnd = m_sinks.end();
+    for (; iter < iterEnd; ++iter)
+    {
+        //try to match source PulseAudio properties agains config properties
+        const char *property_value = pa_proplist_gets(i->proplist, iter->propertyName.c_str());
+
+        if (property_value &&
+            ( std::string::npos != std::string(property_value).find(iter->propertyValue) ||
+              std::string::npos != iter->propertyValue.find(property_value)) )
+        {
+            logInfo("PULSE - source output registered:"
+                , " sourceOutputIndex:", i->index, "sinkID:", iter->sink.sinkID);
+
+            m_sinkToPASourceOutput[iter->sink.sinkID] = i->index;
+
+            //iterate pending connection request
+            // -> if there is a connection pending such that sink input "i" matches source from Connect() - create the connection in pulse
+            std::vector<RoutingSenderPULSEConnection>::iterator iterConn    = m_activeConnections.begin();
+            std::vector<RoutingSenderPULSEConnection>::iterator iterConnEnd = m_activeConnections.end();
+            for (; iterConn < iterConnEnd; ++iterConn)
+            {
+                if (iterConn->sinkID == iter->sink.sinkID)
+                {
+                    logInfo("PULSE - asyncConnect() - connectionID:", iterConn->connectionID,
+                            "move sourceOutputIndex:", m_sinkToPASourceOutput[iterConn->sinkID], "to sourceIndex:", m_sourceToPASource[iterConn->sourceID]);
+
+                    routing_sender_move_source_output(
+                            this->m_paContext,
+                            m_sinkToPASourceOutput[iterConn->sinkID],
+                            m_sourceToPASource[iterConn->sourceID],
+                            this);
+
+                    //TODO: add callback for pulse move source output -> to send confirmation; for the moment directly send confirmation
+                    this->m_routingReceiver->ackConnect(iterConn->handle, iterConn->connectionID, am::E_OK);
+                }
+            }
+
+            break;
+        }
+    }
+}
+
+
+void RoutingSenderPULSE::getSinkInfoCallback(pa_context *c, const pa_sink_info *i, int is_last, void *userdata)
+{
+    if (i != NULL)
+    {
+        if (strcmp("null", i->name) == 0)
+        {
+            this->m_paSinkNullIndex = i->index;
+        }
+
+        //search for corresponding (already registered) Sink
+        std::vector<RoutingSenderPULSESourceSinkConfig>::iterator iter    = m_sinks.begin();
+        std::vector<RoutingSenderPULSESourceSinkConfig>::iterator iterEnd = m_sinks.end();
+        for (; iter < iterEnd; ++iter)
+        {
+            //first try to match the sink name from pulse audio sink name
+            if (iter->sink.name == std::string(i->name))
+            {
+                logInfo("PULSE sink name PA:", i->name, "config name:" ,iter->sink.name);
+                logInfo("PULSE - PA sink:", i->index,
+                        "corresponding to AMGR sink:", iter->sink.sinkID, " - found");
+                m_sinkToPASink[iter->sink.sinkID] = i->index;
+            }
+            else
+            {
+                //try to match sink PulseAudio properties against config properties
+                const char *property_value = pa_proplist_gets(i->proplist, iter->propertyName.c_str());
+
+                if (!property_value) continue;
+
+                if (std::string::npos != iter->propertyValue.find(property_value))
+                {
+                    logInfo("PULSE - PA sink:", i->index,
+                            "corresponding to AMGR sink:", iter->sink.sinkID, " - found");
+
+                    m_sinkToPASink[iter->sink.sinkID] = i->index;
+                }
+            }
+        }
+    }
+    else if (is_last)
+    {
+        routing_sender_get_source_info(this->m_paContext, this);
+        logInfo("PULSE - PA sinks registration completed");
+    }
+}
+
+void RoutingSenderPULSE::getSourceInfoCallback(pa_context *c, const pa_source_info *i, int is_last, void *userdata)
+{
+    if (i != NULL)
+    {
+        if (strcmp("null", i->name) == 0)
+        {
+            this->m_paSourceNullIndex = i->index;
+        }
+
+        //search for corresponding (already registered) Source
+        std::vector<RoutingSenderPULSESourceSinkConfig>::iterator iter    = m_sources.begin();
+        std::vector<RoutingSenderPULSESourceSinkConfig>::iterator iterEnd = m_sources.end();
+        for (; iter < iterEnd; ++iter)
+        {
+            //first try to match the sink name from pulse audio sink name
+            if (iter->sink.name == std::string(i->name))
+            {
+                logInfo("PULSE - PA source:", i->index,
+                        "corresponding to AMGR source:", iter->source.sourceID, " - found");
+                m_sourceToPASource[iter->source.sourceID] = i->index;
+            }
+            else
+            {
+                //try to match source PulseAudio properties against config properties
+                const char *property_value = pa_proplist_gets(i->proplist, iter->propertyName.c_str());
+
+                if (!property_value) continue;
+
+                if (std::string::npos != iter->propertyValue.find(property_value))
+                {
+                    logInfo("PULSE - PA source:", i->index,
+                            "corresponding to AMGR source:", iter->source.sourceID, " - found");
+
+                    m_sourceToPASource[iter->source.sourceID] = i->index;
+                }
+            }
+
+        }
+    }
+    else if (is_last)
+    {
+        this->m_routingReceiver->hookDomainRegistrationComplete(this->m_domain.domainID);
+        logInfo("PULSE - PA sinks and source registration completed");
+        //TODO: - search for existing sink inputs & sources outputs
+    }
+}
-- 
1.7.9.5